mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 15:10:16 +02:00
codetools: auto indent: indent like the last closed
git-svn-id: trunk@22508 -
This commit is contained in:
parent
334ef9e67d
commit
37982c53b3
@ -303,6 +303,7 @@ type
|
||||
Capacity: integer;
|
||||
Top: integer;
|
||||
TopType: TFABBlockType;
|
||||
LastBlockClosed: TBlock;
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
procedure BeginBlock(Typ: TFABBlockType; StartPos: integer);
|
||||
@ -425,6 +426,8 @@ begin
|
||||
Block^.InnerIdent:=-1;
|
||||
Block^.InnerStartPos:=-1;
|
||||
TopType:=Typ;
|
||||
LastBlockClosed.Typ:=bbtNone;
|
||||
LastBlockClosed.StartPos:=0;
|
||||
end;
|
||||
|
||||
procedure TFABBlockStack.EndBlock;
|
||||
@ -432,10 +435,13 @@ begin
|
||||
{$IFDEF ShowCodeBeautifier}
|
||||
DebugLn([GetIndentStr(Top*2),'TFABBlockStack.EndBlock ',FABBlockTypeNames[TopType]]);
|
||||
{$ENDIF}
|
||||
if Top<0 then
|
||||
exit;
|
||||
dec(Top);
|
||||
if Top>=0 then
|
||||
TopType:=Stack[Top].Typ
|
||||
else
|
||||
if Top>=0 then begin
|
||||
LastBlockClosed:=Stack[Top];
|
||||
TopType:=Stack[Top].Typ;
|
||||
end else
|
||||
TopType:=bbtNone;
|
||||
end;
|
||||
|
||||
@ -1576,6 +1582,15 @@ begin
|
||||
exit(true);
|
||||
end;
|
||||
|
||||
if Stack.LastBlockClosed.StartPos>0 then begin
|
||||
// a child block was closed
|
||||
// => indent like the last child block one
|
||||
Indent.Indent:=GetLineIndentWithTabs(Source,
|
||||
Stack.LastBlockClosed.StartPos,DefaultTabWidth);
|
||||
Indent.IndentValid:=true;
|
||||
exit(true);
|
||||
end;
|
||||
|
||||
{$IFDEF VerboseIndenter}
|
||||
DebugLn(['TFullyAutomaticBeautifier.GetIndent parsed code in front: context=',FABBlockTypeNames[Block.Typ],'/',FABBlockTypeNames[SubType],' indent=',GetLineIndentWithTabs(Source,Block.StartPos,DefaultTabWidth)]);
|
||||
{$ENDIF}
|
||||
|
Loading…
Reference in New Issue
Block a user