Skip to content

Commit 81c9cc6

Browse files
committed
bk/2024-09-16-2237
1 parent 1393b33 commit 81c9cc6

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

Src/CodeCompletion/DelphiAIDev.CodeCompletion.Search.pas

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ procedure TDelphiAIDevCodeCompletionSearch.Process(const AContext: IOTAKeyContex
9191
Abort;
9292
end;
9393

94+
//Pegar o nome da tab da unit aberta
95+
FVars.Module := TUtilsOTA.GetCurrentModule;
9496
FVars.Contents.Text := TUtils.ConfReturnAI(FAI.Response.Text);
9597

9698
LRow := LIOTAEditPosition.Row;

Src/CodeCompletion/DelphiAIDev.CodeCompletion.Vars.pas

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ interface
44

55
uses
66
System.SysUtils,
7-
System.Classes;
7+
System.Classes,
8+
ToolsAPI;
89

910
type
1011
TDelphiAIDevCodeCompletionVars = class
1112
private
13+
FRelease: Boolean;
14+
FModule: IOTAModule;
1215
FLineIni: Integer;
1316
FLineEnd: Integer;
1417
FRow: Integer;
@@ -19,6 +22,8 @@ TDelphiAIDevCodeCompletionVars = class
1922
class function GetInstance: TDelphiAIDevCodeCompletionVars;
2023
destructor Destroy; override;
2124
procedure Clear;
25+
property Release: Boolean read FRelease write FRelease;
26+
property Module: IOTAModule read FModule write FModule;
2227
property LineIni: Integer read FLineIni write FLineIni;
2328
property LineEnd: Integer read FLineEnd write FLineEnd;
2429
property Row: Integer read FRow write FRow;
@@ -53,6 +58,8 @@ destructor TDelphiAIDevCodeCompletionVars.Destroy;
5358

5459
procedure TDelphiAIDevCodeCompletionVars.Clear;
5560
begin
61+
FRelease := False;
62+
FModule := nil;
5663
FLineIni := 0;
5764
FLineEnd := 0;
5865
FRow := 0;

Src/IDE/NTAEditViewNotifier/DelphiAIDev.IDE.NTAEditViewNotifier.pas

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,13 @@ procedure TDelphiAIDevIDENTAEditViewNotifier.EditorIdle(const View: IOTAEditView
9696
begin
9797
TUtilsOTA.GetCursorPosition(LRow, LColumn);
9898

99-
if LVars.LineIni > 0 then
99+
//if LVars.LineIni > 0 then
100+
if not LVars.Release then
100101
if (LRow <> LVars.Row) or (LColumn <> LVars.Column) then
101102
begin
102-
LVars.LineIni := 0;
103-
LVars.Clear;
103+
//LVars.LineIni := 0;
104+
//LVars.Clear;
105+
LVars.Release := True;
104106
TUtils.AddLog('EditorIdle');
105107
end;
106108
end;
@@ -120,6 +122,8 @@ procedure TDelphiAIDevIDENTAEditViewNotifier.PaintLine(const View: IOTAEditView;
120122
const Canvas: TCanvas; const TextRect: TRect; const LineRect: TRect; const CellSize: TSize);
121123
var
122124
LLineText: string;
125+
LColCurrent: Integer;
126+
LLineCurrent: Integer;
123127
begin
124128
if LineNumber < 1 then
125129
Exit;
@@ -132,6 +136,26 @@ procedure TDelphiAIDevIDENTAEditViewNotifier.PaintLine(const View: IOTAEditView;
132136
//if LineNumber <> View.CursorPos.Line then
133137
// Exit;
134138

139+
//verificar o nome da tab da unit aberta
140+
if LVars.Release then
141+
begin
142+
LVars.Release := False;
143+
144+
//**
145+
LColCurrent := View.CursorPos.Col;
146+
LLineCurrent := View.CursorPos.Line;
147+
//**
148+
try
149+
View.Buffer.EditPosition.Move(LVars.LineIni, 2);
150+
View.Buffer.EditPosition.Delete(Pred(LVars.Contents.Count));
151+
finally
152+
LVars.Clear;
153+
//**
154+
View.Buffer.EditPosition.Move(LLineCurrent, LColCurrent);
155+
//**
156+
end;
157+
end;
158+
135159
if (LineNumber >= LVars.LineIni)and(LineNumber < LVars.LineEnd) then
136160
begin
137161
Canvas.Brush.Style := bsClear;

0 commit comments

Comments
 (0)