diff --git a/components/synedit/synhighlighterpas.pp b/components/synedit/synhighlighterpas.pp index 3ed041d04d..4d5cbeefbe 100644 --- a/components/synedit/synhighlighterpas.pp +++ b/components/synedit/synhighlighterpas.pp @@ -1798,10 +1798,13 @@ begin end; function TSynPasSyn.Func66: TtkTokenKind; +var + tfb: TPascalCodeFoldBlockType; begin if KeyComp('Type') then begin + tfb := TopPascalCodeFoldBlockType; if (PasCodeFoldRange.BracketNestLevel = 0) - and (TopPascalCodeFoldBlockType in + and (tfb in [cfbtVarType, cfbtLocalVarType, cfbtNone, cfbtProcedure, cfbtAnonymousProcedure, cfbtProgram, cfbtUnit, cfbtUnitSection, cfbtClass, cfbtClassSection, cfbtRecord // if inside a type section in class/record @@ -1812,11 +1815,14 @@ begin fRange := fRange + [rsAfterEqualThenType]; end else begin - if TopPascalCodeFoldBlockType in [cfbtVarType, cfbtLocalVarType] then + if tfb in [cfbtVarType, cfbtLocalVarType] then begin EndPascalCodeFoldBlockLastLine; - if TopPascalCodeFoldBlockType in [cfbtProcedure, cfbtAnonymousProcedure] - then StartPascalCodeFoldBlock(cfbtLocalVarType) - else StartPascalCodeFoldBlock(cfbtVarType); + tfb := TopPascalCodeFoldBlockType; + end; + if not(tfb in [cfbtClass, cfbtClassSection, cfbtRecord]) then + if tfb in [cfbtProcedure, cfbtAnonymousProcedure] + then StartPascalCodeFoldBlock(cfbtLocalVarType) + else StartPascalCodeFoldBlock(cfbtVarType); fRange := fRange + [rsInTypeBlock]; end; end;