From c63cc6f21993ac50f4f41c2f5013c6e79819927b Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 2 Dec 2022 17:57:50 +0100 Subject: [PATCH] Fix Default Language not working for the 1st empty file with empty session Fix #12586 --- PowerEditor/src/ScintillaComponent/Buffer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index f21a0c8ca..a6beebaa2 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -679,6 +679,7 @@ BufferID FileManager::loadFile(const TCHAR* filename, Document doc, int encoding { pPath = backupFileName; } + if (pPath) { FILE* fp = generic_fopen(pPath, TEXT("rb")); @@ -1312,7 +1313,8 @@ BufferID FileManager::newEmptyDocument() 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]; wsprintf(nb, TEXT("%d"), static_cast(nextUntitledNewNumber())); 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); BufferID id = static_cast(newBuf); newBuf->_id = id; + const NewDocDefaultSettings& ndds = (nppParamInst.getNppGUI()).getNewDocDefaultSettings(); + newBuf->_lang = ndds._lang; _buffers.push_back(newBuf); ++_nbBufs;