mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-10 20:56: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;
|
||||
FrontGap: TGapTyp;
|
||||
BeautifyFlags: TBeautifyCodeFlags;
|
||||
BehindPos: LongInt;
|
||||
|
||||
function EndBlockIsOk: boolean;
|
||||
begin
|
||||
@ -5725,6 +5726,30 @@ var
|
||||
if NeedCompletion then begin
|
||||
InsertPos:=CleanCursorPos;
|
||||
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:='';
|
||||
FrontGap:=gtEmptyLine;
|
||||
AfterGap:=gtNewLine;
|
||||
|
Loading…
Reference in New Issue
Block a user