From dfc20b664d60eb1e0cfd255d3626de25ccc53b1b Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 27 Nov 2009 16:50:24 +0000 Subject: [PATCH] codetools: completeblock: skip if target line is not empty or code behind is more indented git-svn-id: trunk@22828 - --- components/codetools/stdcodetools.pas | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index bdf569c766..7c3f640fb7 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -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;