Fix encoding of nfo file cannot be changed bug

Fix #8823, fix #9153, fix #13905, close #15902
This commit is contained in:
Don Ho 2024-12-03 16:30:50 +01:00
parent 28244a5996
commit dd0b557e14
2 changed files with 7 additions and 5 deletions

View File

@ -816,7 +816,10 @@ BufferID FileManager::loadFile(const wchar_t* filename, Document doc, int encodi
newBuf->_timeStamp = fileNameTimestamp; newBuf->_timeStamp = fileNameTimestamp;
// restore the encoding (ANSI based) while opening the existing file // restore the encoding (ANSI based) while opening the existing file
newBuf->setEncoding(-1); if (newBuf->_lang == L_ASCII)
newBuf->setEncoding(NPP_CP_DOS_437);
else
newBuf->setEncoding(-1);
// if not a large file, no file extension, and the language has been detected, we use the detected value // if not a large file, no file extension, and the language has been detected, we use the detected value
if (!newBuf->_isLargeFile && ((newBuf->getLangType() == L_TEXT) && (loadedFileFormat._language != L_TEXT))) if (!newBuf->_isLargeFile && ((newBuf->getLangType() == L_TEXT) && (loadedFileFormat._language != L_TEXT)))

View File

@ -1859,12 +1859,11 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
setSpecialStyle(nfoStyle); setSpecialStyle(nfoStyle);
execute(SCI_STYLECLEARALL); execute(SCI_STYLECLEARALL);
Buffer * buf = MainFileManager.getBufferByID(_currentBufferID); Buffer* buf = MainFileManager.getBufferByID(_currentBufferID);
if (buf->getEncoding() != NPP_CP_DOS_437) if (buf->getEncoding() == NPP_CP_DOS_437)
{ {
buf->setEncoding(NPP_CP_DOS_437); MainFileManager.reloadBuffer(buf);
::SendMessage(_hParent, WM_COMMAND, IDM_FILE_RELOAD, 0);
} }
} }
break; break;