mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-14 01:56:36 +08:00
Make detection of active grid or editor in search/replace dialog more stable.
This commit is contained in:
@ -91,6 +91,8 @@ begin
|
|||||||
_Grid := MainForm.ActiveGrid;
|
_Grid := MainForm.ActiveGrid;
|
||||||
comboSearchIn.Items.Clear;
|
comboSearchIn.Items.Clear;
|
||||||
IsQueryTab := MainForm.IsQueryTab(MainForm.PageControlMain.ActivePageIndex, True);
|
IsQueryTab := MainForm.IsQueryTab(MainForm.PageControlMain.ActivePageIndex, True);
|
||||||
|
SearchText := '';
|
||||||
|
|
||||||
if Assigned(_Editor) then begin
|
if Assigned(_Editor) then begin
|
||||||
ObjName := _('SQL editor');
|
ObjName := _('SQL editor');
|
||||||
if IsQueryTab then
|
if IsQueryTab then
|
||||||
@ -98,7 +100,12 @@ begin
|
|||||||
comboSearchIn.Items.AddObject(ObjName, _Editor);
|
comboSearchIn.Items.AddObject(ObjName, _Editor);
|
||||||
if _Editor.Focused then
|
if _Editor.Focused then
|
||||||
comboSearchIn.ItemIndex := comboSearchIn.Items.Count-1;
|
comboSearchIn.ItemIndex := comboSearchIn.Items.Count-1;
|
||||||
|
if _Editor.SelAvail then
|
||||||
|
SearchText := _Editor.SelText
|
||||||
|
else
|
||||||
|
SearchText := _Editor.WordAtCursor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if Assigned(_Grid) then begin
|
if Assigned(_Grid) then begin
|
||||||
ObjName := _('Data grid');
|
ObjName := _('Data grid');
|
||||||
if IsQueryTab then
|
if IsQueryTab then
|
||||||
@ -106,21 +113,17 @@ begin
|
|||||||
comboSearchIn.Items.AddObject(ObjName, _Grid);
|
comboSearchIn.Items.AddObject(ObjName, _Grid);
|
||||||
if _Grid.Focused then
|
if _Grid.Focused then
|
||||||
comboSearchIn.ItemIndex := comboSearchIn.Items.Count-1;
|
comboSearchIn.ItemIndex := comboSearchIn.Items.Count-1;
|
||||||
|
if Assigned(_Grid.FocusedNode) then
|
||||||
|
SearchText := _Grid.Text[_Grid.FocusedNode, _Grid.FocusedColumn];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if (comboSearchIn.ItemIndex = -1) and (comboSearchIn.Items.Count > 0) then
|
||||||
|
comboSearchIn.ItemIndex := 0;
|
||||||
|
|
||||||
// Prefill search editor with selected text
|
// Prefill search editor with selected text
|
||||||
SearchText := '';
|
|
||||||
if Editor <> nil then begin
|
|
||||||
if Editor.SelAvail then
|
|
||||||
SearchText := Editor.SelText
|
|
||||||
else
|
|
||||||
SearchText := Editor.WordAtCursor;
|
|
||||||
end else begin
|
|
||||||
if Assigned(Grid.FocusedNode) then
|
|
||||||
SearchText := Grid.Text[Grid.FocusedNode, Grid.FocusedColumn];
|
|
||||||
end;
|
|
||||||
if SearchText <> '' then
|
if SearchText <> '' then
|
||||||
comboSearch.Text := SearchText;
|
comboSearch.Text := SearchText;
|
||||||
|
|
||||||
ValidateControls(Sender);
|
ValidateControls(Sender);
|
||||||
comboSearch.SetFocus;
|
comboSearch.SetFocus;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user