diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index 5c504c3da7..fd3a473f8c 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -34,6 +34,7 @@ - complete local variables ToDo: + -add missing method definitions -ProcExists: search procs in ancestors too -VarExists: search vars in ancestors too } @@ -529,8 +530,6 @@ begin +'CleanPosToCodePos'); end; - //writeln('TCodeCompletionCodeTool.AddLocalVariable A2 ',CursorNode<>nil); - // find parent block node at cursor BeginNode:=CursorNode.GetNodeOfType(ctnBeginBlock); if (BeginNode=nil) or (BeginNode.Parent=nil) then begin @@ -538,8 +537,6 @@ begin exit; end; - //writeln('TCodeCompletionCodeTool.AddLocalVariable C '); - // find last 'var' section node VarSectionNode:=BeginNode; while (VarSectionNode<>nil) and (VarSectionNode.Desc<>ctnVarSection) do @@ -552,10 +549,12 @@ begin // there is already a var section // -> append variable VarNode:=VarSectionNode.FirstChild; - Indent:=GetLineIndent(Src,VarNode.StartPos); // search last variable in var section while (VarNode.NextBrother<>nil) do VarNode:=VarNode.NextBrother; + Indent:=GetLineIndent(Src,VarNode.StartPos); + if PositionsInSameLine(Src,VarSectionNode.StartPos,VarNode.StartPos) then + inc(Indent,SourceChangeCache.BeautifyCodeOptions.Indent); InsertPos:=FindLineEndOrCodeAfterPosition(VarNode.EndPos); end else begin // there is no var section yet