mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 20:28:19 +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;
|
||||
|
||||
function TSynPasSyn.Func37: TtkTokenKind;
|
||||
var
|
||||
tbf: TPascalCodeFoldBlockType;
|
||||
begin
|
||||
if KeyComp('Begin') then begin
|
||||
// if we are in an include file, we may not know the state
|
||||
@ -1336,9 +1338,17 @@ begin
|
||||
if TopPascalCodeFoldBlockType in [cfbtVarType, cfbtLocalVarType] then
|
||||
EndPascalCodeFoldBlockLastLine;
|
||||
Result := tkKey;
|
||||
if TopPascalCodeFoldBlockType in [cfbtProcedure]
|
||||
then StartPascalCodeFoldBlock(cfbtTopBeginEnd)
|
||||
else StartPascalCodeFoldBlock(cfbtBeginEnd);
|
||||
tbf := TopPascalCodeFoldBlockType;
|
||||
if tbf in [cfbtProcedure]
|
||||
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));
|
||||
end else
|
||||
if FExtendedKeywordsMode and KeyComp('Break') then
|
||||
|
@ -363,6 +363,45 @@ begin
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]);
|
||||
{%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}
|
||||
SetLines(TestTextFoldInfo2);
|
||||
EnableFolds([cfbtBeginEnd..cfbtNone]-[cfbtRepeat], [cfbtSlashComment]);
|
||||
|
Loading…
Reference in New Issue
Block a user