mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-27 05:29:15 +02:00
codetools: code completion: create local var based on first occurence instead of at cursor, patch #28819 from Ondrej
git-svn-id: trunk@50051 -
This commit is contained in:
parent
b3ff6d8167
commit
6716258279
@ -9141,14 +9141,12 @@ function TCodeCompletionCodeTool.CompleteCode(CursorPos: TCodeXYPosition;
|
||||
if Result then exit;
|
||||
end;
|
||||
|
||||
function TryComplete(CleanCursorPos, OrigCleanCursorPos: integer): Boolean;
|
||||
function TryComplete(CursorNode: TCodeTreeNode; CleanCursorPos, OrigCleanCursorPos: integer): Boolean;
|
||||
var
|
||||
CursorNode: TCodeTreeNode;
|
||||
ProcNode, AClassNode: TCodeTreeNode;
|
||||
IsEventAssignment: boolean;
|
||||
begin
|
||||
Result := False;
|
||||
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
||||
FCompletingCursorNode:=CursorNode;
|
||||
try
|
||||
|
||||
@ -9321,18 +9319,14 @@ begin
|
||||
|
||||
CodeCompleteSrcChgCache:=SourceChangeCache;
|
||||
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
||||
FCompletingCursorNode:=CursorNode;
|
||||
try
|
||||
if TryComplete(CleanCursorPos, OrigCleanCursorPos) then exit;
|
||||
finally
|
||||
FCompletingCursorNode:=nil;
|
||||
end;
|
||||
|
||||
{ Find the first occurence of the (local) identifier at cursor in current
|
||||
procedure body and try again. }
|
||||
Result:=TryFirstLocalIdentOccurence(CursorNode,OrigCleanCursorPos,CleanCursorPos);
|
||||
if Result then exit;
|
||||
|
||||
if TryComplete(CursorNode, CleanCursorPos, OrigCleanCursorPos) then exit;
|
||||
|
||||
{$IFDEF CTDEBUG}
|
||||
DebugLn('TCodeCompletionCodeTool.CompleteCode nothing to complete ... ');
|
||||
{$ENDIF}
|
||||
|
Loading…
Reference in New Issue
Block a user