mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-05 00:02:05 +02:00
codetools: auto indent: added parameter UseLineStart
git-svn-id: trunk@22333 -
This commit is contained in:
parent
1a34693b34
commit
fbac1ba4b8
@ -298,17 +298,13 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure Clear;
|
||||
function GetIndent(const Source: string; CleanPos: integer;
|
||||
NewNestedComments: boolean;
|
||||
NewNestedComments: boolean; UseLineStart: boolean;
|
||||
out Indent: TFABIndentationPolicy): boolean;
|
||||
procedure GetDefaultSrcIndent(const Source: string; CleanPos: integer;
|
||||
NewNestedComments: boolean;
|
||||
out Indent: TFABIndentationPolicy);
|
||||
procedure GetDefaultIndentPolicy(Typ, SubTyp: TFABBlockType;
|
||||
out Indent: TFABIndentationPolicy);
|
||||
{ ToDo:
|
||||
- indent on paste (position + new source)
|
||||
- indent auto generated code (several snippets)
|
||||
}
|
||||
property OnGetExamples: TOnGetFABExamples read FOnGetExamples
|
||||
write FOnGetExamples;
|
||||
property OnGetNestedComments: TOnGetFABNestedComments
|
||||
@ -1040,7 +1036,7 @@ end;
|
||||
|
||||
function TFullyAutomaticBeautifier.GetIndent(const Source: string;
|
||||
CleanPos: integer; NewNestedComments: boolean;
|
||||
out Indent: TFABIndentationPolicy): boolean;
|
||||
UseLineStart: boolean; out Indent: TFABIndentationPolicy): boolean;
|
||||
var
|
||||
Block: TBlock;
|
||||
|
||||
@ -1075,6 +1071,11 @@ begin
|
||||
CleanPos:=FindStartOfAtom(Source,CleanPos);
|
||||
if CleanPos<1 then exit;
|
||||
|
||||
if UseLineStart then begin
|
||||
while (CleanPos<=length(Source)) and (Source[CleanPos] in [' ',#9]) do
|
||||
inc(CleanPos);
|
||||
end;
|
||||
|
||||
Block:=CleanBlock;
|
||||
ParentBlock:=CleanBlock;
|
||||
Policies:=TFABPolicies.Create;
|
||||
|
@ -14455,7 +14455,8 @@ begin
|
||||
if FirstLinePos<SrcEditor.LineCount then
|
||||
DebugLn(['TMainIDE.OnSrcNoteBookGetIndent Firstline+1=',SrcEditor.Lines[FirstLinePos+1]]);
|
||||
NestedComments:=CodeToolBoss.GetNestedCommentsFlagForFile(CodeBuf.Filename);
|
||||
if not CodeToolBoss.Indenter.GetIndent(CodeBuf.Source,p,NestedComments,NewIndent)
|
||||
if not CodeToolBoss.Indenter.GetIndent(CodeBuf.Source,p,NestedComments,
|
||||
true,NewIndent)
|
||||
then exit;
|
||||
if not NewIndent.IndentValid then exit;
|
||||
Indent:=NewIndent.Indent;
|
||||
|
Loading…
Reference in New Issue
Block a user