From 55de911be538d0dde2200a07bffb1fdea72d3c56 Mon Sep 17 00:00:00 2001 From: Don HO Date: Mon, 12 Apr 2021 17:32:19 +0200 Subject: [PATCH] Fix the 1st document title "new 1" is not translated https://github.com/notepad-plus-plus/notepad-plus-plus/commit/1ae39c2dda5f26c5b6a641f5362c8fa65bf70270#commitcomment-49174136 --- PowerEditor/src/ScintillaComponent/Buffer.cpp | 11 +++++------ PowerEditor/src/ScintillaComponent/Buffer.h | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 419f2acc0..20b8b8567 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -497,9 +497,6 @@ void FileManager::init(Notepad_plus * pNotepadPlus, ScintillaEditView * pscratch _pscratchTilla->execute(SCI_SETUNDOCOLLECTION, false); //dont store any undo information _scratchDocDefault = (Document)_pscratchTilla->execute(SCI_GETDOCPOINTER); _pscratchTilla->execute(SCI_ADDREFDOCUMENT, 0, _scratchDocDefault); - - NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); - _untitled_str = pNativeSpeaker->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); } void FileManager::checkFilesystemChanges(bool bCheckOnlyCurrentBuffer) @@ -1087,7 +1084,8 @@ size_t FileManager::nextUntitledNewNumber() const // if untitled document is invisible, then don't put its number into array (so its number is available to be used) if ((buf->_referees[0])->isVisible()) { - TCHAR *numberStr = buf->_fileName + _untitled_str.length(); + generic_string newTitle = ((NppParameters::getInstance()).getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); + TCHAR *numberStr = buf->_fileName + newTitle.length(); int usedNumber = generic_atoi(numberStr); usedNumbers.push_back(usedNumber); } @@ -1123,7 +1121,8 @@ size_t FileManager::nextUntitledNewNumber() const BufferID FileManager::newEmptyDocument() { - generic_string newTitle = _untitled_str; + generic_string newTitle = ((NppParameters::getInstance()).getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); + TCHAR nb[10]; wsprintf(nb, TEXT("%d"), nextUntitledNewNumber()); newTitle += nb; @@ -1140,7 +1139,7 @@ BufferID FileManager::newEmptyDocument() BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool dontRef) { - generic_string newTitle = _untitled_str; + generic_string newTitle = ((NppParameters::getInstance()).getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); TCHAR nb[10]; wsprintf(nb, TEXT("%d"), nextUntitledNewNumber()); newTitle += nb; diff --git a/PowerEditor/src/ScintillaComponent/Buffer.h b/PowerEditor/src/ScintillaComponent/Buffer.h index 013c40615..24635cca2 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.h +++ b/PowerEditor/src/ScintillaComponent/Buffer.h @@ -140,7 +140,6 @@ private: std::vector _buffers; BufferID _nextBufferID = 0; size_t _nbBufs = 0; - generic_string _untitled_str = UNTITLED_STR; }; #define MainFileManager FileManager::getInstance()