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,6 +816,9 @@ 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
if (newBuf->_lang == L_ASCII)
newBuf->setEncoding(NPP_CP_DOS_437);
else
newBuf->setEncoding(-1); 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

View File

@ -1861,10 +1861,9 @@ void ScintillaEditView::defineDocType(LangType typeDoc)
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;