From 578935181135c423c99fa8b5224095b7c86b5f5f Mon Sep 17 00:00:00 2001 From: Martijn Laan <1092369+martijnlaan@users.noreply.github.com> Date: Sun, 16 Jun 2024 19:31:20 +0200 Subject: [PATCH] Comment changes. --- Components/ScintEdit.pas | 2 ++ Components/ScintStylerInnoSetup.pas | 31 ++++++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Components/ScintEdit.pas b/Components/ScintEdit.pas index 775664a47..71d6f0419 100644 --- a/Components/ScintEdit.pas +++ b/Components/ScintEdit.pas @@ -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); diff --git a/Components/ScintStylerInnoSetup.pas b/Components/ScintStylerInnoSetup.pas index ce9d8d741..9b3755856 100644 --- a/Components/ScintStylerInnoSetup.pas +++ b/Components/ScintStylerInnoSetup.pas @@ -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, @@ -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;