Fix FuncList not refresh correctly due to large files perf improving

Fix #16221 completely
This commit is contained in:
Don Ho 2025-03-07 17:02:20 +01:00
parent 829cd9d119
commit 8793825b34
4 changed files with 21 additions and 10 deletions

View File

@ -6702,14 +6702,6 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask)
return; return;
} }
if (mask & (BufferChangeLanguage))
{
if (mainActive)
_autoCompleteMain.setLanguage(buffer->getLangType());
if (subActive)
_autoCompleteSub.setLanguage(buffer->getLangType());
}
if ((currentView() == MAIN_VIEW) && !mainActive) if ((currentView() == MAIN_VIEW) && !mainActive)
return; return;
@ -6732,9 +6724,9 @@ void Notepad_plus::notifyBufferChanged(Buffer * buffer, int mask)
{ {
checkLangsMenu(-1); //let Notepad++ do search for the item checkLangsMenu(-1); //let Notepad++ do search for the item
setLangStatus(buffer->getLangType()); setLangStatus(buffer->getLangType());
if (_mainEditView.getCurrentBuffer() == buffer) if (mainActive)
_autoCompleteMain.setLanguage(buffer->getLangType()); _autoCompleteMain.setLanguage(buffer->getLangType());
else if (_subEditView.getCurrentBuffer() == buffer) else if (subActive)
_autoCompleteSub.setLanguage(buffer->getLangType()); _autoCompleteSub.setLanguage(buffer->getLangType());
if (_pFuncList && (!_pFuncList->isClosed()) && _pFuncList->isVisible()) if (_pFuncList && (!_pFuncList->isClosed()) && _pFuncList->isVisible())

View File

@ -4135,6 +4135,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return TRUE; return TRUE;
} }
case NPPM_INTERNAL_RELOADFUNCTIONLIST:
{
if (_pFuncList && (!_pFuncList->isClosed()) && _pFuncList->isVisible())
{
_pFuncList->reload();
}
return TRUE;
}
default: default:
{ {
if (message == WDN_NOTIFY) if (message == WDN_NOTIFY)

View File

@ -1723,6 +1723,10 @@ void ScintillaEditView::setLanguage(LangType langType)
if (_currentBuffer->getLastLangType() > 0 && !_currentBuffer->isUntitled()) 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(); saveCurrentPos();
Document prev = execute(SCI_GETDOCPOINTER); Document prev = execute(SCI_GETDOCPOINTER);
execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF); execute(SCI_SETMODEVENTMASK, MODEVENTMASK_OFF);
@ -1738,6 +1742,11 @@ void ScintillaEditView::setLanguage(LangType langType)
maintainStateForNpc(); maintainStateForNpc();
setCRLF(); setCRLF();
restoreCurrentPosPreStep(); 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 else
{ {

View File

@ -745,6 +745,7 @@
#define NPPM_INTERNAL_LWINDENT (NOTEPADPLUS_USER_INTERNAL + 105) #define NPPM_INTERNAL_LWINDENT (NOTEPADPLUS_USER_INTERNAL + 105)
#define NPPM_INTERNAL_CHECKDOCSTATUS (NOTEPADPLUS_USER_INTERNAL + 106) #define NPPM_INTERNAL_CHECKDOCSTATUS (NOTEPADPLUS_USER_INTERNAL + 106)
#define NPPM_INTERNAL_HIDEMENURIGHTSHORTCUTS (NOTEPADPLUS_USER_INTERNAL + 107) #define NPPM_INTERNAL_HIDEMENURIGHTSHORTCUTS (NOTEPADPLUS_USER_INTERNAL + 107)
#define NPPM_INTERNAL_RELOADFUNCTIONLIST (NOTEPADPLUS_USER_INTERNAL + 108)