mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-22 21:34:58 +02:00
Fix regression of folding state not being remembered through sessions
The regression is introduced by:
83755ca155 (diff-d88ddee57a027ab23daf332c4778ced0cee352edcb34efdda1b218e8a75c61b2L2636)
The culprit of this regression is the deletion of following 4 lines in the commit above:
```
void ScintillaEditView::fold(size_t line, bool mode, bool shouldBeNotified/* = true*/)
{
auto endStyled = execute(SCI_GETENDSTYLED);
auto len = execute(SCI_GETTEXTLENGTH);
if (endStyled < len)
execute(SCI_COLOURISE, 0, -1);
```
The method "ScintillaEditView::fold()" is called not only on manual folding by the users, but also on:
1. startup's loading session to restore the folding state programmatically.
2. after startup, switching among the documents to restore the folding state programmatically.
The above lines are important for the case 1.
However, these lines are necessary only on the first load of each file after the startup of Notepad++.
"execute(SCI_COLOURISE, 0, -1);" needs to be run for once (the case 1), not twice or more (the case 2).
So if there's a way to detect if a document has been run "execute(SCI_COLOURISE, 0, -1);" once (in the case 1),
and don't run it again (the case 2), it will save the time to switch among the document.
Fix #16597, close #16599
This commit is contained in:
parent
19a1897eaa
commit
1f48115666
@ -2521,6 +2521,7 @@ bool Notepad_plus::loadSession(Session & session, bool isSnapshotMode, const wch
|
||||
allSessionFilesLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (mainIndex2Update != -1)
|
||||
{
|
||||
_isFolding = true;
|
||||
|
@ -2592,6 +2592,27 @@ bool ScintillaEditView::isCurrentLineFolded() const
|
||||
|
||||
void ScintillaEditView::fold(size_t line, bool mode, bool shouldBeNotified/* = true*/)
|
||||
{
|
||||
auto endStyled = execute(SCI_GETENDSTYLED);
|
||||
auto len = execute(SCI_GETTEXTLENGTH);
|
||||
|
||||
if (endStyled < len)
|
||||
execute(SCI_COLOURISE, 0, -1);
|
||||
/*
|
||||
The method ScintillaEditView::fold() is called not only on manual folding by the users, but also on:
|
||||
|
||||
1. startup's loading session to restore the folding state programmatically.
|
||||
2. after startup, switching among the documents to restore the folding state programmatically.
|
||||
|
||||
The above lines are important for the case 1.
|
||||
|
||||
However, these lines are necessary only on the first load of each file after the startup of Notepad++.
|
||||
"execute(SCI_COLOURISE, 0, -1);" needs to be run for once (the case 1), not twice or more (the case 2).
|
||||
|
||||
So if there's a way to detect if a document has been run "execute(SCI_COLOURISE, 0, -1);" once (in the case 1),
|
||||
and don't run it again (the case 2), it will save the time to switch among the document.
|
||||
*/
|
||||
|
||||
|
||||
intptr_t headerLine;
|
||||
auto level = execute(SCI_GETFOLDLEVEL, line);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user