diff --git a/components/synedit/syneditfoldedview.pp b/components/synedit/syneditfoldedview.pp index 856a03e805..7e7b91996c 100644 --- a/components/synedit/syneditfoldedview.pp +++ b/components/synedit/syneditfoldedview.pp @@ -2210,6 +2210,8 @@ begin n := o; for i := hl.FoldNodeInfoCount[aStartIndex] - 1 downto 0 do begin nd := hl.FoldNodeInfo[aStartIndex, i]; + if not(sfaFold in nd.FoldAction) then + continue; t := nd.FoldGroup; if sfaOpen in nd.FoldAction then begin dec(n); diff --git a/components/synedit/synedithighlighterfoldbase.pas b/components/synedit/synedithighlighterfoldbase.pas index 49581268c1..2ac7e2173a 100644 --- a/components/synedit/synedithighlighterfoldbase.pas +++ b/components/synedit/synedithighlighterfoldbase.pas @@ -101,6 +101,7 @@ type TSynFoldAction = (sfaOpen, // At this node a new Fold can start sfaClose, // At this node a fold ends sfaMarkup, // This node can be highlighted, by the matching Word-Pair Markup + sfaFold, // Part of a foldable block sfaInvalid // Wrong Index ); TSynFoldActions = set of TSynFoldAction; diff --git a/components/synedit/synhighlighterpas.pp b/components/synedit/synhighlighterpas.pp index 7c9f6dfec4..d37df767d9 100644 --- a/components/synedit/synhighlighterpas.pp +++ b/components/synedit/synhighlighterpas.pp @@ -2767,8 +2767,9 @@ begin if FCatchNodeInfo then begin // exclude subblocks, because they do not increase the foldlevel yet GrowNodeInfoList; InitNode(FNodeInfoList[FNodeInfoCount], +1, ABlockType); -// if not SubBlock then - include(FNodeInfoList[FNodeInfoCount].FoldAction, sfaOpen); + if FoldBlock then + include(FNodeInfoList[FNodeInfoCount].FoldAction, sfaFold); + include(FNodeInfoList[FNodeInfoCount].FoldAction, sfaOpen); inc(FNodeInfoCount); end; if not FoldBlock then @@ -2783,8 +2784,9 @@ begin if FCatchNodeInfo then begin // exclude subblocks, because they do not increase the foldlevel yet GrowNodeInfoList; InitNode(FNodeInfoList[FNodeInfoCount], -1, TopPascalCodeFoldBlockType); -// if DecreaseLevel then - include(FNodeInfoList[FNodeInfoCount].FoldAction, sfaClose); + if DecreaseLevel then + include(FNodeInfoList[FNodeInfoCount].FoldAction, sfaFold); + include(FNodeInfoList[FNodeInfoCount].FoldAction, sfaClose); inc(FNodeInfoCount); end; inherited EndCodeFoldBlock(DecreaseLevel);