diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index 969bd4b49..f0fa3ca45 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -1329,7 +1329,7 @@ BufferID FileManager::newEmptyDocument() return id; } -BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool dontRef) +BufferID FileManager::bufferFromDocument(Document doc) { NppParameters& nppParamInst = NppParameters::getInstance(); generic_string newTitle = (nppParamInst.getNativeLangSpeaker())->getLocalizedStrFromID("tab-untitled-string", UNTITLED_STR); @@ -1337,8 +1337,6 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d wsprintf(nb, TEXT("%d"), static_cast(nextUntitledNewNumber())); newTitle += nb; - if (!dontRef) - _pscratchTilla->execute(SCI_ADDREFDOCUMENT, 0, doc); //set reference for FileManager Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str(), false); BufferID id = newBuf; newBuf->_id = id; @@ -1347,8 +1345,7 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d _buffers.push_back(newBuf); ++_nbBufs; - if (!dontIncrease) - ++_nextBufferID; + ++_nextBufferID; return id; } diff --git a/PowerEditor/src/ScintillaComponent/Buffer.h b/PowerEditor/src/ScintillaComponent/Buffer.h index 1775c7184..ed6f4bf16 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.h +++ b/PowerEditor/src/ScintillaComponent/Buffer.h @@ -87,10 +87,9 @@ public: BufferID loadFile(const TCHAR * filename, Document doc = static_cast(NULL), int encoding = -1, const TCHAR *backupFileName = nullptr, FILETIME fileNameTimestamp = {}); //ID == BUFFER_INVALID on failure. If Doc == NULL, a new file is created, otherwise data is loaded in given document BufferID newEmptyDocument(); - //create Buffer from existing Scintilla, used from new Scintillas. If dontIncrease = true, then the new document number isnt increased afterwards. - //usefull for temporary but neccesary docs - //If dontRef = false, then no extra reference is added for the doc. Its the responsibility of the caller to do so - BufferID bufferFromDocument(Document doc, bool dontIncrease = false, bool dontRef = false); + + //create Buffer from existing Scintilla, used from new Scintillas. + BufferID bufferFromDocument(Document doc); BufferID getBufferFromName(const TCHAR * name); BufferID getBufferFromDocument(Document doc); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index 15107e4ce..271c3685d 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -1881,7 +1881,7 @@ BufferID ScintillaEditView::attachDefaultDoc() // get the doc pointer attached (by default) on the view Scintilla Document doc = execute(SCI_GETDOCPOINTER, 0, 0); execute(SCI_ADDREFDOCUMENT, 0, doc); - BufferID id = MainFileManager.bufferFromDocument(doc, false, true);//true, true); //keep counter on 1 + BufferID id = MainFileManager.bufferFromDocument(doc); Buffer * buf = MainFileManager.getBufferByID(id); MainFileManager.addBufferReference(id, this); //add a reference. Notepad only shows the buffer in tabbar