IDE Scout: Execute editor commands with a delay so the selection window has time to hide. Issue #34383.

This commit is contained in:
Juha 2024-08-03 17:23:12 +03:00
parent 1cae4b5382
commit d51777fee4

View File

@ -122,8 +122,7 @@ Type
procedure LBMatchesClick(Sender: TObject); procedure LBMatchesClick(Sender: TObject);
procedure LBMatchesDrawItem(Control: TWinControl; Index: Integer; procedure LBMatchesDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; {%H-}State: TOwnerDrawState); ARect: TRect; {%H-}State: TOwnerDrawState);
procedure LBMatchesKeyUp(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState procedure LBMatchesKeyUp(Sender: TObject; var Key: Word; {%H-}Shift: TShiftState);
);
private private
FRefresh, FRefresh,
FHighlights: TScoutTerrains; FHighlights: TScoutTerrains;
@ -131,6 +130,7 @@ Type
FMatchColor: TColor; FMatchColor: TColor;
FShowCategory: Boolean; FShowCategory: Boolean;
FSearchItems: TStringListUTF8Fast; FSearchItems: TStringListUTF8Fast;
FSelectedIdx: Integer;
FOrgCaption : String; FOrgCaption : String;
FShowShortCutKey: Boolean; FShowShortCutKey: Boolean;
procedure ClearRefreshableItems; procedure ClearRefreshableItems;
@ -138,6 +138,7 @@ Type
Procedure RefreshList; Procedure RefreshList;
procedure FillRecent(aType: TIDERecentHandler); procedure FillRecent(aType: TIDERecentHandler);
Procedure Initialize; Procedure Initialize;
procedure ExecuteOnIdle(Sender: TObject; var Done: Boolean);
procedure ExecuteSelected; procedure ExecuteSelected;
Procedure FillCommands; Procedure FillCommands;
procedure FilterList(aSearchTerm: String); procedure FilterList(aSearchTerm: String);
@ -534,6 +535,8 @@ procedure TIDEScoutForm.FormCreate(Sender: TObject);
begin begin
FSearchItems:=TStringListUTF8Fast.Create; FSearchItems:=TStringListUTF8Fast.Create;
FSearchItems.OwnsObjects:=True; FSearchItems.OwnsObjects:=True;
FSelectedIdx:=-1;
Application.AddOnIdleHandler(@ExecuteOnIdle);
Caption:=isrsIDEScout; Caption:=isrsIDEScout;
FOrgCaption:=Caption; FOrgCaption:=Caption;
ESearch.TextHint:=isrsTypeSearchTerms; ESearch.TextHint:=isrsTypeSearchTerms;
@ -626,25 +629,30 @@ begin
end; end;
end; end;
procedure TIDEScoutForm.ExecuteSelected; procedure TIDEScoutForm.ExecuteOnIdle(Sender: TObject; var Done: Boolean);
Var Var
idx: Integer; Itm : TSearchItem;
itm : TSearchItem;
begin begin
Idx:=LBMatches.ItemIndex; if FSelectedIdx=-1 then exit;
if (Idx>=0) then Itm:=LBMatches.Items.Objects[FSelectedIdx] as TSearchItem;
begin if Itm.Source is TIDECommand then
TIDECommand(Itm.Source).Execute(SourceEditorManagerIntf.ActiveEditor)
else if Itm.Source is TComponentItem then
TComponentItem(Itm.Source).Execute
else if Itm.Source is TOpenFileItem then
TOpenFileItem(Itm.Source).Execute;
FSelectedIdx:=-1;
Done:=True;
end;
procedure TIDEScoutForm.ExecuteSelected;
begin
FSelectedIdx:=LBMatches.ItemIndex;
if FSelectedIdx>=0 then
begin
Hide; Hide;
Itm:=LBMatches.Items.Objects[Idx] as TSearchItem; sleep(10);
if Itm.Source is TIDECommand then end;
TIDECommand(Itm.Source).Execute(SourceEditorManagerIntf.ActiveEditor)
else if Itm.Source is TComponentItem then
TComponentItem(Itm.Source).Execute
else if Itm.Source is TOpenFileItem then
TOpenFileItem(Itm.Source).Execute;
end;
end; end;