Skip to content

Commit c1a97c2

Browse files
committed
bk/2024-09-16-2350
1 parent 81c9cc6 commit c1a97c2

File tree

2 files changed

+53
-18
lines changed

2 files changed

+53
-18
lines changed

Src/CodeCompletion/DelphiAIDev.CodeCompletion.Search.pas

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

94-
//Pegar o nome da tab da unit aberta
9594
FVars.Module := TUtilsOTA.GetCurrentModule;
9695
FVars.Contents.Text := TUtils.ConfReturnAI(FAI.Response.Text);
9796

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

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ TDelphiAIDevIDENTAEditViewNotifier = class(TInterfacedObject, IOTANotifier, IN
5151
procedure BeforeSave;
5252
procedure Modified;
5353
procedure Destroyed;
54+
55+
//TDelphiAIDevIDENTAEditViewNotifier
56+
procedure ClearLinesNotUsed;
5457
end;
5558

5659
implementation
@@ -96,8 +99,8 @@ procedure TDelphiAIDevIDENTAEditViewNotifier.EditorIdle(const View: IOTAEditView
9699
begin
97100
TUtilsOTA.GetCursorPosition(LRow, LColumn);
98101

99-
//if LVars.LineIni > 0 then
100-
if not LVars.Release then
102+
if LVars.LineIni > 0 then
103+
//if LVars.Release then
101104
if (LRow <> LVars.Row) or (LColumn <> LVars.Column) then
102105
begin
103106
//LVars.LineIni := 0;
@@ -117,13 +120,38 @@ procedure TDelphiAIDevIDENTAEditViewNotifier.Modified;
117120

118121
end;
119122

123+
procedure TDelphiAIDevIDENTAEditViewNotifier.ClearLinesNotUsed;
124+
var
125+
LView: IOTAEditView;
126+
LColCurrent: Integer;
127+
LLineCurrent: Integer;
128+
begin
129+
LVars.Release := False;
130+
131+
if LVars.Module = nil then
132+
Exit;
133+
134+
TUtils.AddLog(sLineBreak + LVars.Module.FileName + sLineBreak + TUtilsOTA.GetCurrentModule.FileName);
135+
136+
//if LVars.Module.FileName <> TUtilsOTA.GetCurrentModule.FileName then
137+
// Exit;
138+
139+
LView := TUtilsOTA.GetIOTAEditView(LVars.Module);
140+
LColCurrent := LView.CursorPos.Col;
141+
LLineCurrent := LView.CursorPos.Line;
142+
try
143+
LView.Buffer.EditPosition.Move(LVars.LineIni, 2);
144+
LView.Buffer.EditPosition.Delete(Pred(LVars.Contents.Count));
145+
finally
146+
LView.Buffer.EditPosition.Move(LLineCurrent, LColCurrent);
147+
end;
148+
end;
149+
120150
procedure TDelphiAIDevIDENTAEditViewNotifier.PaintLine(const View: IOTAEditView; LineNumber: Integer;
121151
const LineText: PAnsiChar; const TextWidth: Word; const LineAttributes: TOTAAttributeArray;
122152
const Canvas: TCanvas; const TextRect: TRect; const LineRect: TRect; const CellSize: TSize);
123153
var
124154
LLineText: string;
125-
LColCurrent: Integer;
126-
LLineCurrent: Integer;
127155
begin
128156
if LineNumber < 1 then
129157
Exit;
@@ -133,27 +161,35 @@ procedure TDelphiAIDevIDENTAEditViewNotifier.PaintLine(const View: IOTAEditView;
133161
if not LLineText.Trim.IsEmpty then
134162
Exit;
135163

136-
//if LineNumber <> View.CursorPos.Line then
137-
// Exit;
138164

139-
//verificar o nome da tab da unit aberta
165+
//if LineNumber <> View.CursorPos.Line then Exit;
166+
140167
if LVars.Release then
141168
begin
169+
try
170+
Self.ClearLinesNotUsed;
171+
finally
172+
LVars.Clear;
173+
end;
174+
175+
{TUtils.AddLog(sLineBreak + LVars.Module.FileName + sLineBreak + TUtilsOTA.GetCurrentModule.FileName);
142176
LVars.Release := False;
143177
144-
//**
145-
LColCurrent := View.CursorPos.Col;
146-
LLineCurrent := View.CursorPos.Line;
147-
//**
148178
try
149-
View.Buffer.EditPosition.Move(LVars.LineIni, 2);
150-
View.Buffer.EditPosition.Delete(Pred(LVars.Contents.Count));
179+
if LVars.Module.FileName = TUtilsOTA.GetCurrentModule.FileName then
180+
begin
181+
LColCurrent := View.CursorPos.Col;
182+
LLineCurrent := View.CursorPos.Line;
183+
try
184+
View.Buffer.EditPosition.Move(LVars.LineIni, 2);
185+
View.Buffer.EditPosition.Delete(Pred(LVars.Contents.Count));
186+
finally
187+
View.Buffer.EditPosition.Move(LLineCurrent, LColCurrent);
188+
end;
189+
end
151190
finally
152191
LVars.Clear;
153-
//**
154-
View.Buffer.EditPosition.Move(LLineCurrent, LColCurrent);
155-
//**
156-
end;
192+
end;}
157193
end;
158194

159195
if (LineNumber >= LVars.LineIni)and(LineNumber < LVars.LineEnd) then

0 commit comments

Comments
 (0)