From 24c557392ff0913389dcf6ea5725663e5b0beb66 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Mon, 3 Aug 2015 01:31:17 +0200 Subject: [PATCH] [BUG_FIXED] Fix inconsistant untitled name issue. The inconsistant untitled name issue is the first untitled document name is "new 0" or "new 2" instead of "new 1". This fix make the first untitled document name always be "new 1". --- PowerEditor/src/ScitillaComponent/Buffer.cpp | 12 ++++++++---- PowerEditor/src/ScitillaComponent/Buffer.h | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index add3092d7..8be39de17 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -1052,9 +1052,13 @@ size_t FileManager::nextUntitledNewNumber() const Buffer *buf = _buffers.at(i); if (buf->isUntitled()) { - TCHAR *numberStr = buf->_fileName + lstrlen(UNTITLED_STR); - int usedNumber = generic_atoi(numberStr); - usedNumbers.push_back(usedNumber); + // 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 + lstrlen(UNTITLED_STR); + int usedNumber = generic_atoi(numberStr); + usedNumbers.push_back(usedNumber); + } } } @@ -1106,7 +1110,7 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d { generic_string newTitle = UNTITLED_STR; TCHAR nb[10]; - wsprintf(nb, TEXT("%d"), 0); + wsprintf(nb, TEXT("%d"), nextUntitledNewNumber()); newTitle += nb; if (!dontRef) diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index dc9c0140e..655e205c1 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -346,7 +346,7 @@ private : bool _needLexer; //initially true //these properties have to be duplicated because of multiple references //All the vectors must have the same size at all times - std::vector< ScintillaEditView * > _referees; + std::vector< ScintillaEditView * > _referees; // Instances of ScintillaEditView which contain this buffer std::vector< Position > _positions; std::vector< std::vector > _foldStates;