diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 62a938275..98e862146 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -6702,14 +6702,6 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) return; } - if (mask & (BufferChangeLanguage)) - { - if (mainActive) - _autoCompleteMain.setLanguage(buffer->getLangType()); - if (subActive) - _autoCompleteSub.setLanguage(buffer->getLangType()); - } - if ((currentView() == MAIN_VIEW) && !mainActive) return; @@ -6732,9 +6724,9 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask) { checkLangsMenu(-1); //let Notepad++ do search for the item setLangStatus(buffer->getLangType()); - if (_mainEditView.getCurrentBuffer() == buffer) + if (mainActive) _autoCompleteMain.setLanguage(buffer->getLangType()); - else if (_subEditView.getCurrentBuffer() == buffer) + else if (subActive) _autoCompleteSub.setLanguage(buffer->getLangType()); if (_pFuncList && (!_pFuncList->isClosed()) && _pFuncList->isVisible()) diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index 01c988afc..19b26bda2 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -4135,6 +4135,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa return TRUE; } + case NPPM_INTERNAL_RELOADFUNCTIONLIST: + { + if (_pFuncList && (!_pFuncList->isClosed()) && _pFuncList->isVisible()) + { + _pFuncList->reload(); + } + return TRUE; + } + default: { if (message == WDN_NOTIFY) diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index a8abc5eb7..98f7d61d6 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -1723,6 +1723,10 @@ void ScintillaEditView::setLanguage(LangType langType) if (_currentBuffer->getLastLangType() > 0 && !_currentBuffer->isUntitled()) { + // To improve switching lexer performance, here's the tip: + // 1. Set current document to a blank document + // 2. Set a new lexer + // 3. Reset back to the current document saveCurrentPos(); Document prev = execute(SCI_GETDOCPOINTER); execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF); @@ -1738,6 +1742,11 @@ void ScintillaEditView::setLanguage(LangType langType) maintainStateForNpc(); setCRLF(); restoreCurrentPosPreStep(); + + // When buffer sets lang type ("_currentBuffer->setLangType(langType);"), it'll call doNotify(BufferChangeLanguage | BufferChangeLexing), + // then FunctionList will be reloaded. However, it'll be reloaded on the blank document. + // That's why here we do again FunctionList reload, after the current document be reset back. + ::SendMessage(_hParent, NPPM_INTERNAL_RELOADFUNCTIONLIST, 0, 0); } else { diff --git a/PowerEditor/src/resource.h b/PowerEditor/src/resource.h index 1117177a4..8f0d69054 100644 --- a/PowerEditor/src/resource.h +++ b/PowerEditor/src/resource.h @@ -745,6 +745,7 @@ #define NPPM_INTERNAL_LWINDENT (NOTEPADPLUS_USER_INTERNAL + 105) #define NPPM_INTERNAL_CHECKDOCSTATUS (NOTEPADPLUS_USER_INTERNAL + 106) #define NPPM_INTERNAL_HIDEMENURIGHTSHORTCUTS (NOTEPADPLUS_USER_INTERNAL + 107) + #define NPPM_INTERNAL_RELOADFUNCTIONLIST (NOTEPADPLUS_USER_INTERNAL + 108)