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:
mattias 2009-11-27 16:50:24 +00:00
parent 3ed535c5f2
commit dfc20b664d

View File

@ -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;