diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 805ee4775..4455b0a14 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -4650,10 +4650,6 @@ void Notepad_plus::loadBufferIntoView(BufferID id, int whichOne, bool dontClose) { idToClose = BUFFER_INVALID; } - else - { - buf->setLastLangType(-1); // When replacing the "new" tab with an opened file, the last used language should be reset to its initial value so that the language can be reloaded later in the activateBuffer() function. - } } MainFileManager.addBufferReference(id, viewToOpen); diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 2387a78b1..b06708e60 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -3720,7 +3720,6 @@ void Notepad_plus::command(int id) // Manually set language, don't change language even file extension changes. Buffer *buffer = _pEditView->getCurrentBuffer(); buffer->langHasBeenSetFromMenu(); - buffer->setLastLangType(static_cast(lang)); if (_pDocMap) { diff --git a/PowerEditor/src/ScintillaComponent/Buffer.h b/PowerEditor/src/ScintillaComponent/Buffer.h index 606678fb4..109f0f866 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.h +++ b/PowerEditor/src/ScintillaComponent/Buffer.h @@ -217,10 +217,6 @@ public: void setLangType(LangType lang, const wchar_t * userLangName = L""); - int getLastLangType() const { return _lastLangType; } - - void setLastLangType(int val) { _lastLangType = val; } - UniMode getUnicodeMode() const { return _unicodeMode; } void setUnicodeMode(UniMode mode); @@ -393,7 +389,6 @@ private: //document properties Document _doc; //invariable LangType _lang = L_TEXT; - int _lastLangType = -1; std::wstring _userLangExt; // it's useful if only (_lang == L_USER) bool _isDirty = false; EolType _eolFormat = EolType::osdefault; diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index 40d620882..f3ca30fdd 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -2133,16 +2133,6 @@ void ScintillaEditView::defineDocType(LangType typeDoc) } } -Document ScintillaEditView::getBlankDocument() -{ - if (!_blankDocument) - { - _blankDocument = static_cast(execute(SCI_CREATEDOCUMENT, 0, SC_DOCUMENTOPTION_TEXT_LARGE)); - execute(SCI_ADDREFDOCUMENT, 0, _blankDocument); - } - return _blankDocument; -} - BufferID ScintillaEditView::attachDefaultDoc() { // get the doc pointer attached (by default) on the view Scintilla @@ -2309,57 +2299,19 @@ void ScintillaEditView::activateBuffer(BufferID buffer, bool force) // put the state into the future ex buffer _currentBuffer->setHeaderLineState(lineStateVector, this); - _prevBuffer = _currentBuffer; - _currentBufferID = buffer; //the magical switch happens here _currentBuffer = newBuf; - const bool isSameLangType = (_prevBuffer != nullptr) && (_prevBuffer->getLangType() == _currentBuffer->getLangType()) && - (_currentBuffer->getLangType() != L_USER || wcscmp(_prevBuffer->getUserDefineLangName(), _currentBuffer->getUserDefineLangName()) == 0); - - const int currentLangInt = static_cast(_currentBuffer->getLangType()); - const bool isFirstActiveBuffer = (_currentBuffer->getLastLangType() != currentLangInt); - unsigned long MODEVENTMASK_ON = NppParameters::getInstance().getScintillaModEventMask(); - if (isFirstActiveBuffer) // Entering the tab for the 1st time - { - // change the doc, this operation will decrease - // the ref count of old current doc and increase the one of the new doc. FileManager should manage the rest - // Note that the actual reference in the Buffer itself is NOT decreased, Notepad_plus does that if neccessary - execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF); - execute(SCI_SETDOCPOINTER, 0, _currentBuffer->getDocument()); - execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON); - // Due to execute(SCI_CLEARDOCUMENTSTYLE); in defineDocType() function - // defineDocType() function should be called here, but not be after the fold info loop - defineDocType(_currentBuffer->getLangType()); - } - else if (isSameLangType) // After the 2nd entering with the same language type - { - // No need to call defineDocType() since it's the same language type - execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF); - execute(SCI_SETDOCPOINTER, 0, _currentBuffer->getDocument()); - execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON); + // change the doc, this operation will decrease + // the ref count of old current doc and increase the one of the new doc. FileManager should manage the rest + // Note that the actual reference in the Buffer itself is NOT decreased, Notepad_plus does that if neccessary + execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF); + execute(SCI_SETDOCPOINTER, 0, _currentBuffer->getDocument()); + execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON); - if (force) - defineDocType(_currentBuffer->getLangType()); - } - else // Entering the tab for the 2nd or more times, with the different language type - { - // In order to improve the performance of switch-in on the 2nd or more times for the large files, - // a blank document is used for accelerate defineDocType() call. - execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF); - execute(SCI_SETDOCPOINTER, 0, getBlankDocument()); - execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON); - - defineDocType(_currentBuffer->getLangType()); - - execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF); - execute(SCI_SETDOCPOINTER, 0, _currentBuffer->getDocument()); - execute(SCI_SETMODEVENTMASK, MODEVENTMASK_ON); - } - - _currentBuffer->setLastLangType(currentLangInt); + defineDocType(_currentBuffer->getLangType()); setWordChars(); maintainStateForNpc(); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h index dd8cccfb0..47e328870 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h @@ -432,11 +432,6 @@ public: virtual void destroy() { - if (_blankDocument != 0) - { - execute(SCI_RELEASEDOCUMENT, 0, _blankDocument); - _blankDocument = 0; - } ::DestroyWindow(_hSelf); _hSelf = NULL; _pScintillaFunc = NULL; @@ -862,8 +857,6 @@ public: bool pasteToMultiSelection() const; void setElementColour(int element, COLORREF color) const { execute(SCI_SETELEMENTCOLOUR, element, color | 0xFF000000); }; - Document getBlankDocument(); - protected: static bool _SciInit; @@ -885,10 +878,7 @@ protected: //Store the current buffer so it can be retrieved later BufferID _currentBufferID = nullptr; - Buffer * _currentBuffer = nullptr; - - Buffer* _prevBuffer = nullptr; - Document _blankDocument = 0; + Buffer* _currentBuffer = nullptr; int _codepage = CP_ACP; bool _wrapRestoreNeeded = false;