Skip to content

Commit

Permalink
Comment changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Jun 16, 2024
1 parent aa041e2 commit 5789351
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 2 additions & 0 deletions Components/ScintEdit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,8 @@ procedure TScintEdit.StyleNeeded(const EndPos: Integer);
var OldState := FLines.GetState(I);
if FStyler.FLineState <> OldState then
Call(SCI_SETLINESTATE, I, FStyler.FLineState);
{ To display/debug fold levels use: Call(SCI_SETFOLDFLAGS, SC_FOLDFLAG_LEVELNUMBERS, 0);
And then also update UpdateLineNumbersWidth to make the margin wider. }
var OldLevel := Call(SCI_GETFOLDLEVEL, I, 0);
if FoldLevel <> OldLevel then
Call(SCI_SETFOLDLEVEL, I, FoldLevel);
Expand Down
31 changes: 17 additions & 14 deletions Components/ScintStylerInnoSetup.pas
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ interface

type
TInnoSetupStylerSection = (
scNone, { Not inside a section (start of file, or last section was closed) }
scNone, { Not inside a section (start of file, or previous section was closed with )
Section tags themselves are not associated with any section! }
scUnknown, { Inside an unrecognized section }
scThirdParty, { Inside a '_' section (reserved for third-party tools) }
scCode,
Expand Down Expand Up @@ -939,24 +940,26 @@ function TInnoSetupStyler.GetFlagsWordList(Section: TInnoSetupStylerSection): An
procedure TInnoSetupStyler.GetFoldLevel(const LineState: TScintLineState;
var Level: Integer; var Header: Boolean);
begin
{ Set folding per section. To keep our code as simple as possible we simply
give all lines outside of a section (=lines at the start of the document and
section tags and section end tags and lines after section end tags) a header
flag. This avoids having to look at the previous line. Doesn't mean
Scintilla will display folding markers on all these header lines: it only
does that when there is something to fold, so when the header line is
followed a by non-header line which is only the case for a section tag line
followed by a section line.
Did notice an issue (Scintilla automatic folding bug?): Add a section with
some lines. Collapse it. Break the section header for example by removing ']'.
Scintialla now auto expands the section and removes the fold mark.
Retype the ']'. Scintilla now displays the old fold mark to expand the
section but it's already expanded. }

var Section := TInnoSetupStyler.GetSectionFromLineState(LineState);
if Section <> scNone then begin
Level := 1;
Header := False;
end else begin
{ Everything outside a section should have the header flag, even if it's just
a blank line or a comment. Doing this doesn't cause many fold markers: if
two lines have the same level and header flag the first line doesn't get a
fold mark since there's nothing to expand. Not doing this however is a
problem: for example, if the first line is empty and and the second line
starts a section then those two lines would logically considered to be in
the same 'fold' and edits on the first line would affect the section if
collapsed.
Did notice an issue (Scintilla bug?): Add a section with some lines.
Collapse it. Break the section header for example by removing ']'.
Scintialla now auto expands the section and removes the fold mark.
Retype the ']'. Scintilla now displays the old fold mark to expand the
section but it's already expanded. }
Level := 0;
Header := True;
end;
Expand Down

0 comments on commit 5789351

Please sign in to comment.