Skip to content

Commit 18c009b

Browse files
committed
bk/2024-08-29-1654
1 parent dc5e4db commit 18c009b

File tree

5 files changed

+32
-30
lines changed

5 files changed

+32
-30
lines changed

Src/CodeCompletion/DelphiAIDev.CodeCompletion.Search.pas

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,19 @@ procedure TDelphiAIDevCodeCompletionSearch.Process(const AContext: IOTAKeyContex
6666
begin
6767
FSettings.ValidateFillingSelectedAI(TShowMsg.No);
6868

69+
6970
FQuestions.Clear;
7071
FQuestions.Add(FSettings.LanguageQuestions.GetLanguageDefinition);
7172
FQuestions.Add(FSettings.LanguageQuestions.GetMsgCodeCompletionSuggestion);
7273
FQuestions.Add(FSettings.LanguageQuestions.GetMsgCodeOnly);
73-
FQuestions.Add(TUtilsOTA.GetSelectedBlockOrAllCodeUnit.Trim);
74+
75+
LIOTAEditPosition := AContext.EditBuffer.EditPosition;
76+
LIOTAEditPosition.InsertText(TConsts.TAG_CODE_COMPLETION);
77+
try
78+
FQuestions.Add(TUtilsOTA.GetSelectedBlockOrAllCodeUnit.Trim);
79+
finally
80+
LIOTAEditPosition.BackspaceDelete(TConsts.TAG_CODE_COMPLETION.Length);
81+
end;
7482

7583
//TUtils.ShowMsg('CodeCompletionSearch.Process - FQuestions.Text', FQuestions.Text);
7684
try
@@ -82,7 +90,6 @@ procedure TDelphiAIDevCodeCompletionSearch.Process(const AContext: IOTAKeyContex
8290
FVars.Contents.Text := TUtils.ConfReturnAI(FChat.Response.Text);
8391
//TUtils.ShowMsg('CodeCompletionSearch.Process - FVars.Contents.Text', FVars.Contents.Text);
8492

85-
LIOTAEditPosition := AContext.EditBuffer.EditPosition;
8693
LRow := LIOTAEditPosition.Row;
8794
LColumn := LIOTAEditPosition.Column;
8895

Src/Consts/DelphiAIDev.Consts.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ TConsts = class
2424
MARK_BEGIN_SQL2 = '``sql';
2525
MARK_END = '```';
2626
PREFIX_NAME_SEPARATOR = 'DelphiAIDevSeparator';
27+
TAG_CODE_COMPLETION = '//Suggestion_Code_Delphi';
2728

2829
//SETTINGS
2930
KEY_SETTINGS_IN_WINDOWS_REGISTRY = '\SOFTWARE\DelphiAIDeveloper';

Src/KeyboardBinding/DelphiAIDev.KeyboardBinding.pas

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -100,26 +100,6 @@ procedure TDelphiAIDevKeyboardBinding.KeyProcBlockReturnAndAlt(const Context: IO
100100
end;
101101
end;
102102

103-
procedure TDelphiAIDevKeyboardBinding.KeyAltHome(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
104-
var
105-
LTextCurrentLineOrBlock: string;
106-
begin
107-
if KeyCode <> Shortcut(VK_RETURN, [ssAlt]) then
108-
Exit;
109-
110-
LTextCurrentLineOrBlock := GetCurrentLineOrBlock(CnOtaGetTopMostEditView).Trim;
111-
if LTextCurrentLineOrBlock.Trim.IsEmpty then
112-
Exit;
113-
114-
if copy(LTextCurrentLineOrBlock, 1, 2) = '//' then
115-
LTextCurrentLineOrBlock := copy(LTextCurrentLineOrBlock, 3, LTextCurrentLineOrBlock.Length);
116-
117-
DelphiAIDev.Chat.View.DelphiAIDevChatView.QuestionOnShow := LTextCurrentLineOrBlock;
118-
DelphiAIDev.Chat.View.DelphiAIDevChatViewShowDockableForm;
119-
120-
BindingResult := TKeyBindingResult.krUnhandled;
121-
end;
122-
123103
procedure TDelphiAIDevKeyboardBinding.KeyTab(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
124104
var
125105
LText: string;
@@ -144,6 +124,26 @@ procedure TDelphiAIDevKeyboardBinding.KeyTab(const Context: IOTAKeyContext; KeyC
144124
BindingResult := TKeyBindingResult.krUnhandled;
145125
end;
146126

127+
procedure TDelphiAIDevKeyboardBinding.KeyAltHome(const Context: IOTAKeyContext; KeyCode: TShortcut; var BindingResult: TKeyBindingResult);
128+
var
129+
LTextCurrentLineOrBlock: string;
130+
begin
131+
if KeyCode <> Shortcut(VK_RETURN, [ssAlt]) then
132+
Exit;
133+
134+
LTextCurrentLineOrBlock := GetCurrentLineOrBlock(CnOtaGetTopMostEditView).Trim;
135+
if LTextCurrentLineOrBlock.Trim.IsEmpty then
136+
Exit;
137+
138+
if copy(LTextCurrentLineOrBlock, 1, 2) = '//' then
139+
LTextCurrentLineOrBlock := copy(LTextCurrentLineOrBlock, 3, LTextCurrentLineOrBlock.Length);
140+
141+
DelphiAIDev.Chat.View.DelphiAIDevChatView.QuestionOnShow := LTextCurrentLineOrBlock;
142+
DelphiAIDev.Chat.View.DelphiAIDevChatViewShowDockableForm;
143+
144+
BindingResult := TKeyBindingResult.krUnhandled;
145+
end;
146+
147147
initialization
148148

149149
finalization

Src/Test/DelphiAIDev.Test.pas

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ TDelphiAIDevTest = class
1313
FEmail: string;
1414
FDataNascimento: TDateTime;
1515
FApelido: string;
16+
FCep: Integer;
1617
public
1718
property Nome: string read FNome write FNome;
1819
property Endereco: string read FEndereco write FEndereco;
@@ -21,17 +22,13 @@ TDelphiAIDevTest = class
2122
property Telefone: string read FTelefone write FTelefone;
2223
property Email: string read FEmail write FEmail;
2324
property DataNascimento: TDateTime read FDataNascimento write FDataNascimento;
24-
//Suggestion
2525
property Apelido: string read FApelido write FApelido;
26+
property Cep: Integer read FCep write FCep;
2627

2728
procedure Clear;
2829
end;
2930

3031
implementation
3132

32-
procedure TDelphiAIDevTest.Clear;
33-
begin
34-
35-
end;
3633

3734
end.

Src/Utils/DelphiAIDev.Utils.OTA.pas

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,7 @@ class function TUtilsOTA.EditorAsString(AIOTAModule: IOTAModule): string;
309309

310310
LOTASourceEditor := Self.GetIOTASourceEditor(AIOTAModule);
311311
if LOTASourceEditor = nil then
312-
begin
313-
//TUtils.ShowMsgSynchronize('Unable to get SourceEditor.');
314312
Exit;
315-
end;
316313

317314
LIOTAEditReader := LOTASourceEditor.CreateReader;
318315
try

0 commit comments

Comments
 (0)