Improve performance: Optimize activateBuffer function

Ref: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/15952#issuecomment-2567521808

Close #16010
This commit is contained in:
Don Ho 2025-01-03 08:25:27 +01:00
parent c17d1d428d
commit c5dd85cd93
2 changed files with 27 additions and 1 deletions

View File

@ -2358,7 +2358,8 @@ void ScintillaEditView::activateBuffer(BufferID buffer, bool force)
restoreCurrentPosPreStep(); restoreCurrentPosPreStep();
runMarkers(true, 0, true, false); //runMarkers(true, 0, true, false);
restoreHiddenLines();
setCRLF(); setCRLF();
@ -4226,6 +4227,30 @@ void ScintillaEditView::runMarkers(bool doHide, size_t searchStart, bool endOfDo
} }
} }
void ScintillaEditView::restoreHiddenLines()
{
int line = 0;
while (line != -1)
{
line = static_cast<int>(execute(SCI_MARKERNEXT, line, 1 << MARK_HIDELINESBEGIN));
if (line != -1)
{
int startHiding = line + 1;
line = static_cast<int>(execute(SCI_MARKERNEXT, line, 1 << MARK_HIDELINESEND));
if (line != -1)
{
execute(SCI_HIDELINES, startHiding, line - 1);
}
}
}
}
void ScintillaEditView::setTabSettings(Lang* lang) void ScintillaEditView::setTabSettings(Lang* lang)
{ {

View File

@ -815,6 +815,7 @@ public:
bool markerMarginClick(intptr_t lineNumber); //true if it did something bool markerMarginClick(intptr_t lineNumber); //true if it did something
void notifyMarkers(Buffer * buf, bool isHide, size_t location, bool del); void notifyMarkers(Buffer * buf, bool isHide, size_t location, bool del);
void runMarkers(bool doHide, size_t searchStart, bool endOfDoc, bool doDelete); void runMarkers(bool doHide, size_t searchStart, bool endOfDoc, bool doDelete);
void restoreHiddenLines();
bool hasSelection() const { return !execute(SCI_GETSELECTIONEMPTY); }; bool hasSelection() const { return !execute(SCI_GETSELECTIONEMPTY); };