I thought due to [this 
comment](https://github.com/geany/geany/pull/2695#issuecomment-748722240) the 
request for an option was dropped? I think all this started over not closing 
#2693 as a duplicate of #758 and not reading the discussion there.

Key points (duplicated across issues):
1) The goal of #758 and #2693 is to update the search text in the Find and 
Replace dialogs __whenever <kbd>Ctrl</kbd>+<kbd>f</kbd> is pressed, rather than 
only the first time the dialogs are shown__. This seems like a totally 
reasonable behaviour that most applications that have a Find feature do.
2) There was a misunderstanding in both issues where it was believed that the 
goal was to update the search text in the Find and Replace dialogs __whenever 
the selection was changed__ (which would indeed be weird), thus prompting for a 
request about needing an option to turn this feature off.
3) It was clarified that the intention is **1** and not **2** so __no option is 
needed__.

I assume this issue is a duplicate of #2695 because a PR is bound the branch on 
which it was created, and it [was 
suggested](https://github.com/geany/geany/pull/2695#issuecomment-748728322) to 
not use `master` branch for the PR (a good suggestion for future PRs but not 
really essential/required).

If the above summary is accurate, then all that's needed is a patch like this:

```diff
diff --git a/src/search.c b/src/search.c
index 82682ae33..f45d7b477 100644
--- a/src/search.c
+++ b/src/search.c
@@ -575,14 +575,16 @@ void search_show_find_dialog(void)
        }
        else
        {
-               /* only set selection if the dialog is not already visible */
-               if (! gtk_widget_get_visible(find_dlg.dialog) && sel)
+               if (sel != NULL)
+               {
+                       /* update the search text from current selection */
                        gtk_entry_set_text(GTK_ENTRY(find_dlg.entry), sel);
+                       /* reset the entry widget's background colour */
+                       ui_set_search_entry_background(find_dlg.entry, TRUE);
+               }
                gtk_widget_grab_focus(find_dlg.entry);
                set_dialog_position(find_dlg.dialog, find_dlg.position);
                gtk_widget_show(find_dlg.dialog);
-               if (sel != NULL) /* when we have a selection, reset the entry 
widget's background colour */
-                       ui_set_search_entry_background(find_dlg.entry, TRUE);
                /* bring the dialog back in the foreground in case it is 
already open but the focus is away */
                gtk_window_present(GTK_WINDOW(find_dlg.dialog));
        }
@@ -751,11 +753,13 @@ void search_show_replace_dialog(void)
        }
        else
        {
-               /* only set selection if the dialog is not already visible */
-               if (! gtk_widget_get_visible(replace_dlg.dialog) && sel)
+               if (sel != NULL)
+               {
+                       /* update the search text from current selection */
                        gtk_entry_set_text(GTK_ENTRY(replace_dlg.find_entry), 
sel);
-               if (sel != NULL) /* when we have a selection, reset the entry 
widget's background colour */
+                       /* reset the entry widget's background colour */
                        ui_set_search_entry_background(replace_dlg.find_entry, 
TRUE);
+               }
                gtk_widget_grab_focus(replace_dlg.find_entry);
                set_dialog_position(replace_dlg.dialog, replace_dlg.position);
                gtk_widget_show(replace_dlg.dialog);
@@ -1059,10 +1063,8 @@ void search_show_find_in_files_dialog_full(const gchar 
*text, const gchar *dir)
 
        if (!text)
        {
-               /* only set selection if the dialog is not already visible, or 
has just been created */
-               if (doc && ! sel && ! gtk_widget_get_visible(fif_dlg.dialog))
+               if (doc && ! sel)
                        sel = editor_get_default_selection(doc->editor, 
search_prefs.use_current_word, NULL);
-
                text = sel;
        }
        entry = gtk_bin_get_child(GTK_BIN(fif_dlg.search_combo));
```

If that's the case, I propose to update the title and description of this PR 
and to force push a commit similar to above patch. I'm currently on vacation 
and will have time to merge this in the next days. @etkaar your work on this is 
appreciated!

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/2697#issuecomment-749156210

Reply via email to