Fix Default Language not working for the 1st empty file with empty session

Fix #12586
This commit is contained in:
Don Ho 2022-12-02 17:57:50 +01:00
parent f400b682b5
commit c63cc6f219

View File

@ -679,6 +679,7 @@ BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding
{ {
pPath = backupFileName; pPath = backupFileName;
} }
if (pPath) if (pPath)
{ {
FILE* fp = generic_fopen(pPath, TEXT("rb")); FILE* fp = generic_fopen(pPath, TEXT("rb"));
@ -1312,7 +1313,8 @@ BufferID FileManager::newEmptyDocument()
BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool dontRef) BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool dontRef)
{ {
generic_string newTitle = ((NppParameters::getInstance()).getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); NppParameters& nppParamInst = NppParameters::getInstance();
generic_string newTitle = (nppParamInst.getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR);
TCHAR nb[10]; TCHAR nb[10];
wsprintf(nb, TEXT("%d"), static_cast<int>(nextUntitledNewNumber())); wsprintf(nb, TEXT("%d"), static_cast<int>(nextUntitledNewNumber()));
newTitle += nb; newTitle += nb;
@ -1322,6 +1324,8 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d
Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str(), false); Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str(), false);
BufferID id = static_cast<BufferID>(newBuf); BufferID id = static_cast<BufferID>(newBuf);
newBuf->_id = id; newBuf->_id = id;
const NewDocDefaultSettings& ndds = (nppParamInst.getNppGUI()).getNewDocDefaultSettings();
newBuf->_lang = ndds._lang;
_buffers.push_back(newBuf); _buffers.push_back(newBuf);
++_nbBufs; ++_nbBufs;