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

Fix #12586
pull/12596/head
Don Ho 2022-12-02 17:57:50 +01:00
parent f400b682b5
commit c63cc6f219
1 changed files with 5 additions and 1 deletions

View File

@ -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<int>(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<BufferID>(newBuf);
newBuf->_id = id;
const NewDocDefaultSettings& ndds = (nppParamInst.getNppGUI()).getNewDocDefaultSettings();
newBuf->_lang = ndds._lang;
_buffers.push_back(newBuf);
++_nbBufs;