Skip to content

Commit

Permalink
Set SC_FOLDLEVELWHITEFLAG as best as we can. Missed some cases. For o…
Browse files Browse the repository at this point in the history
…ur intended folding I beleive it doesn't matter since we only display markers on folder headers.
  • Loading branch information
martijnlaan committed Jun 16, 2024
1 parent 17beb30 commit e11f027
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Components/ScintEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit e11f027

Please sign in to comment.