From 439624bd977bdd51e31fb8c62dd7588cd671b453 Mon Sep 17 00:00:00 2001 From: Martijn Laan <1092369+martijnlaan@users.noreply.github.com> Date: Sun, 16 Jun 2024 09:27:36 +0200 Subject: [PATCH] =?UTF-8?q?Simplify=20to=20make=20it=20work=20better=20on?= =?UTF-8?q?=20edits.=20This=20way=20Scintilla=20doesnt=20expand=20sections?= =?UTF-8?q?=20when=20editing=20above=20them=20and=20also=20it=20doesnt=20r?= =?UTF-8?q?emove=20whitespace=20lines=20at=20the=20end=20of=20a=20collapse?= =?UTF-8?q?d=20section=20when=20the=20section=20tag=20is=20removed=20(like?= =?UTF-8?q?=20by=20deleting=20]).=20=F0=9F=98=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Components/ScintEdit.pas | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/Components/ScintEdit.pas b/Components/ScintEdit.pas index 43ec1f50d..0a013e333 100644 --- a/Components/ScintEdit.pas +++ b/Components/ScintEdit.pas @@ -1812,18 +1812,10 @@ 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 := ''; + { Set line states and also add fold headers when not in a section. } for var I := FirstLine to LastLine do begin var OldState := FLines.GetState(I); @@ -1831,19 +1823,10 @@ procedure TScintEdit.StyleNeeded(const EndPos: Integer); Call(SCI_SETLINESTATE, I, FStyler.FLineState); 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 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 or ExtraFlags); - end; - end else - Call(SCI_SETFOLDLEVEL, I, SC_FOLDLEVELBASE or ExtraFlags); + if Section <> scNone then + Call(SCI_SETFOLDLEVEL, I, SC_FOLDLEVELBASE+1) + else + Call(SCI_SETFOLDLEVEL, I, SC_FOLDLEVELBASE or SC_FOLDLEVELHEADERFLAG); end; Result := LastLine;