From e11f02735325fec4889c9913d1599c6a6ae91d44 Mon Sep 17 00:00:00 2001 From: Martijn Laan <1092369+martijnlaan@users.noreply.github.com> Date: Sun, 16 Jun 2024 08:38:40 +0200 Subject: [PATCH] Set SC_FOLDLEVELWHITEFLAG as best as we can. Missed some cases. For our intended folding I beleive it doesn't matter since we only display markers on folder headers. --- Components/ScintEdit.pas | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Components/ScintEdit.pas b/Components/ScintEdit.pas index ba07d9279..357f11541 100644 --- a/Components/ScintEdit.pas +++ b/Components/ScintEdit.pas @@ -1791,12 +1791,19 @@ procedure TScintEdit.StyleNeeded(const EndPos: Integer); Call(SCI_SETSTYLINGEX, Length(FStyler.FStyleStr), LPARAM(PAnsiChar(FStyler.FStyleStr))); FStyler.FStyleStr := ''; - FStyler.FText := ''; end; { Set line states and also add fold headers at section tags. These appear with section scNone with the next line not being section sNone. } + var ExtraFlags := 0; + if FStyler.FText = '' then begin + { All spanned lines are empty. If only some lines are empty we miss this. } + ExtraFlags := ExtraFlags or SC_FOLDLEVELWHITEFLAG; + end; + + FStyler.FText := ''; + for var I := FirstLine to LastLine do begin var OldState := FLines.GetState(I); if FStyler.FLineState <> OldState then @@ -1805,17 +1812,17 @@ procedure TScintEdit.StyleNeeded(const EndPos: Integer); var Section := TInnoSetupStyler.GetSectionFromLineState(FStyler.LineState); if Section <> scNone then begin { We're in a section, make this line as level 1 } - Call(SCI_SETFOLDLEVEL, I, SC_FOLDLEVELBASE+1); + Call(SCI_SETFOLDLEVEL, I, SC_FOLDLEVELBASE+1 or ExtraFlags); { Also look at previous line to see if was the section tag, and if so retroactively set it as a folder header } if I > 0 then begin var PrevState := FLines.GetState(I-1); var PrevSection := TInnoSetupStyler.GetSectionFromLineState(PrevState); if PrevSection = scNone then - Call(SCI_SETFOLDLEVEL, I-1, SC_FOLDLEVELBASE or SC_FOLDLEVELHEADERFLAG); + Call(SCI_SETFOLDLEVEL, I-1, SC_FOLDLEVELBASE or SC_FOLDLEVELHEADERFLAG or ExtraFlags); end; end else - Call(SCI_SETFOLDLEVEL, I, SC_FOLDLEVELBASE); + Call(SCI_SETFOLDLEVEL, I, SC_FOLDLEVELBASE or ExtraFlags); end; Result := LastLine;