mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-09 00:38:18 +02:00
SynEdit: Pas-HL, fix nested fold-blocks if some kind of blocks are disabled in config. ("end" keyword was attributed to wrong block)
This commit is contained in:
parent
bc8f26b1e8
commit
939301e105
@ -1327,6 +1327,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TSynPasSyn.Func37: TtkTokenKind;
|
function TSynPasSyn.Func37: TtkTokenKind;
|
||||||
|
var
|
||||||
|
tbf: TPascalCodeFoldBlockType;
|
||||||
begin
|
begin
|
||||||
if KeyComp('Begin') then begin
|
if KeyComp('Begin') then begin
|
||||||
// if we are in an include file, we may not know the state
|
// if we are in an include file, we may not know the state
|
||||||
@ -1336,9 +1338,17 @@ begin
|
|||||||
if TopPascalCodeFoldBlockType in [cfbtVarType, cfbtLocalVarType] then
|
if TopPascalCodeFoldBlockType in [cfbtVarType, cfbtLocalVarType] then
|
||||||
EndPascalCodeFoldBlockLastLine;
|
EndPascalCodeFoldBlockLastLine;
|
||||||
Result := tkKey;
|
Result := tkKey;
|
||||||
if TopPascalCodeFoldBlockType in [cfbtProcedure]
|
tbf := TopPascalCodeFoldBlockType;
|
||||||
then StartPascalCodeFoldBlock(cfbtTopBeginEnd)
|
if tbf in [cfbtProcedure]
|
||||||
else StartPascalCodeFoldBlock(cfbtBeginEnd);
|
then StartPascalCodeFoldBlock(cfbtTopBeginEnd, True)
|
||||||
|
else StartPascalCodeFoldBlock(cfbtBeginEnd, tbf in [
|
||||||
|
cfbtProgram, cfbtUnit, cfbtUnitSection, cfbtPackage,
|
||||||
|
cfbtTopBeginEnd, cfbtBeginEnd,
|
||||||
|
cfbtTry, cfbtExcept, cfbtAsm,
|
||||||
|
cfbtCase, cfbtCaseElse,
|
||||||
|
// TODO: cfbtIfThen..cfbtWithDo => only if they are nested in one of the above
|
||||||
|
cfbtIfThen, cfbtIfElse, cfbtForDo, cfbtWhileDo, cfbtWithDo
|
||||||
|
]);
|
||||||
//debugln('TSynPasSyn.Func37 BEGIN ',dbgs(ord(TopPascalCodeFoldBlockType)),' LineNumber=',dbgs(fLineNumber),' ',dbgs(MinimumNestFoldBlockLevel),' ',dbgs(CurrentCodeFoldBlockLevel));
|
//debugln('TSynPasSyn.Func37 BEGIN ',dbgs(ord(TopPascalCodeFoldBlockType)),' LineNumber=',dbgs(fLineNumber),' ',dbgs(MinimumNestFoldBlockLevel),' ',dbgs(CurrentCodeFoldBlockLevel));
|
||||||
end else
|
end else
|
||||||
if FExtendedKeywordsMode and KeyComp('Break') then
|
if FExtendedKeywordsMode and KeyComp('Break') then
|
||||||
|
@ -363,6 +363,45 @@ begin
|
|||||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
|
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
|
||||||
{%endregion}
|
{%endregion}
|
||||||
|
|
||||||
|
{%region}
|
||||||
|
SetLines(TestTextFoldInfo1);
|
||||||
|
EnableFolds([cfbtBeginEnd..cfbtNone]-[cfbtBeginEnd]);
|
||||||
|
PopPushBaseName('Text 1 all folds, except cfbtBeginEnd');
|
||||||
|
|
||||||
|
AssertEquals('Len Prog', 10, PasHighLighter.FoldLineLength(0,0));
|
||||||
|
AssertEquals('Len Proc', 7, PasHighLighter.FoldLineLength(1,0));
|
||||||
|
AssertEquals('Len IF A', 2, PasHighLighter.FoldLineLength(2,0));
|
||||||
|
AssertEquals('Len Begin', 5, PasHighLighter.FoldLineLength(3,0));
|
||||||
|
AssertEquals('Len if beg (not avail)', -1, PasHighLighter.FoldLineLength(5,0));
|
||||||
|
//AssertEquals('Len PrgBeg', 1, PasHighLighter.FoldLineLength(9,0));
|
||||||
|
|
||||||
|
AssertEquals('Len invalid', -1, PasHighLighter.FoldLineLength(4,0)); // endif
|
||||||
|
AssertEquals('Len // (no hide)', -1, PasHighLighter.FoldLineLength(11,0));
|
||||||
|
|
||||||
|
// Pg pc $I bg $E be w e e be e //
|
||||||
|
CheckFoldOpenCounts('', [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||||
|
{%endregion}
|
||||||
|
|
||||||
|
{%region}
|
||||||
|
SetLines(TestTextFoldInfo1);
|
||||||
|
EnableFolds([cfbtBeginEnd..cfbtNone]-[cfbtBeginEnd,cfbtTopBeginEnd]);
|
||||||
|
PopPushBaseName('Text 1 all folds, except cfbtBeginEnd,cfbtTopBeginEnd');
|
||||||
|
|
||||||
|
AssertEquals('Len Prog', 10, PasHighLighter.FoldLineLength(0,0));
|
||||||
|
AssertEquals('Len Proc', 7, PasHighLighter.FoldLineLength(1,0));
|
||||||
|
AssertEquals('Len IF A', 2, PasHighLighter.FoldLineLength(2,0));
|
||||||
|
AssertEquals('Len Begin (not avail)', -1, PasHighLighter.FoldLineLength(3,0));
|
||||||
|
AssertEquals('Len if beg (not avail)', -1, PasHighLighter.FoldLineLength(5,0));
|
||||||
|
//AssertEquals('Len PrgBeg', 1, PasHighLighter.FoldLineLength(9,0));
|
||||||
|
|
||||||
|
AssertEquals('Len // (no hide)', -1, PasHighLighter.FoldLineLength(11,0));
|
||||||
|
|
||||||
|
// Pg pc $I bg $E be w e e be e //
|
||||||
|
CheckFoldOpenCounts('', [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
|
||||||
|
{%endregion}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{%region}
|
{%region}
|
||||||
SetLines(TestTextFoldInfo2);
|
SetLines(TestTextFoldInfo2);
|
||||||
EnableFolds([cfbtBeginEnd..cfbtNone]-[cfbtRepeat], [cfbtSlashComment]);
|
EnableFolds([cfbtBeginEnd..cfbtNone]-[cfbtRepeat], [cfbtSlashComment]);
|
||||||
|
Loading…
Reference in New Issue
Block a user