mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 19:59:14 +02:00
codetools: completeblock: skip if target line is not empty or code behind is more indented
git-svn-id: trunk@22828 -
This commit is contained in:
parent
3ed535c5f2
commit
dfc20b664d
@ -5432,6 +5432,7 @@ var
|
|||||||
AfterGap: TGapTyp;
|
AfterGap: TGapTyp;
|
||||||
FrontGap: TGapTyp;
|
FrontGap: TGapTyp;
|
||||||
BeautifyFlags: TBeautifyCodeFlags;
|
BeautifyFlags: TBeautifyCodeFlags;
|
||||||
|
BehindPos: LongInt;
|
||||||
|
|
||||||
function EndBlockIsOk: boolean;
|
function EndBlockIsOk: boolean;
|
||||||
begin
|
begin
|
||||||
@ -5725,6 +5726,30 @@ var
|
|||||||
if NeedCompletion then begin
|
if NeedCompletion then begin
|
||||||
InsertPos:=CleanCursorPos;
|
InsertPos:=CleanCursorPos;
|
||||||
Indent:=CursorBlockOuterIndent;
|
Indent:=CursorBlockOuterIndent;
|
||||||
|
|
||||||
|
// check code behind
|
||||||
|
BehindPos:=FindNextNonSpace(Src,InsertPos);
|
||||||
|
if BehindPos<=SrcLen then begin
|
||||||
|
if PositionsInSameLine(Src,InsertPos,BehindPos) then begin
|
||||||
|
// target line not empty
|
||||||
|
{$IFDEF ShowCompleteBlock}
|
||||||
|
DebugLn(['CompleteStatements target line not empty => skip']);
|
||||||
|
{$ENDIF}
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
if (GetLineIndent(Src,BehindPos)>Indent) then begin
|
||||||
|
// code behind is more indented
|
||||||
|
// for example
|
||||||
|
// repeat
|
||||||
|
// |
|
||||||
|
// DoSomething;
|
||||||
|
{$IFDEF ShowCompleteBlock}
|
||||||
|
DebugLn(['CompleteStatements code behind is indented more => skip']);
|
||||||
|
{$ENDIF}
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
NewCode:='';
|
NewCode:='';
|
||||||
FrontGap:=gtEmptyLine;
|
FrontGap:=gtEmptyLine;
|
||||||
AfterGap:=gtNewLine;
|
AfterGap:=gtNewLine;
|
||||||
|
Loading…
Reference in New Issue
Block a user