drracket icon indicating copy to clipboard operation
drracket copied to clipboard

CTRL+F find should automatically put hilighted/selected text in searchbox

Open jestarray opened this issue 1 month ago • 14 comments

https://github.com/user-attachments/assets/b39826b3-b8ea-4017-8457-d48b21111ebf

jestarray avatar Nov 11 '25 19:11 jestarray

side topic: soegaard said on discord if there's a hotkey to close the searchbox with just the keyboard only. In chrome, pressing escape closes the searchbox so I guess we should follow that?

jestarray avatar Nov 11 '25 19:11 jestarray

esc closes the search bar if you are in the search bar and type it (so, ctrl-f followed by esc if you're not)

I think automatically overwriting the contents of the search window when entering it would disrupt the way I usually edit with DrRacket. Maybe type c-c, c-f, c-v? That's what I do when I want that behavior.

rfindler avatar Nov 11 '25 20:11 rfindler

It would only overwrite if there was a new selection, right? I just tried this out in Firefox and it does the overwriting if there's a selection, and continues searching for the previous thing if there isn't a selection.

samth avatar Nov 11 '25 21:11 samth

It would only overwrite if there was a new selection, right? I just tried this out in Firefox and it does the overwriting if there's a selection, and continues searching for the previous thing if there isn't a selection.

yep, only when there's a different selection does it override the search box. If this would break most peoples workflows, maybe put it behind ctrl+f+f(double tap)? Or have it as an option in preferences? I'm just so used to vscode and webbrowsers doing this automatically so my opinion differs.

jestarray avatar Nov 11 '25 22:11 jestarray

Are there any popular browsers and IDEs that don't do this? In my experience, it's been universal.

jackfirth avatar Nov 11 '25 22:11 jackfirth

Oh, I see. Thanks for explaining. Seems worth experimenting with.

rfindler avatar Nov 11 '25 23:11 rfindler

On macOS, I just tried:

  • Firefox
  • Safari
  • TextEdit and Notes (macOS's built in text editors)
  • Sublime Text

And none of them have this behavior. That is, selecting some text and typing cmd-f opens the search bar without changing the search bar's content.

rfindler avatar Nov 12 '25 01:11 rfindler

I tried some macOS programs too. These do it:

  • Chrome
  • VS Code

jackfirth avatar Nov 12 '25 03:11 jackfirth

I think we must be doing something differently. Google Chrome didn't do it for me. I selected some text and then typed "cmd-f". The selected text was "copy" and the search bar contained "color". The search bar wasn't open when I typed cmd-f. I also tried selecting "Explore more features" and then typing cmd-c (copy) followed by cmd-f: the search text was still "color".

rfindler avatar Nov 12 '25 03:11 rfindler

Here's what I just did, with chrome on this github page (on Linux):

  1. Hit ctrl-f. The search text box is empty.
  2. Close the search box.
  3. Select "The selected text".
  4. Press ctrl-f.
  5. The search box opens. It contains "The selected text", which is also itself selected in that search box.
  6. Select "the search bar". (note that the search box is still open but not selected)
  7. Press ctrl-f.
  8. The content of the search box changes to "the search bar" and it is selected.
  9. Close the search box.
  10. Select "something differently".
  11. Press ctrl-f.
  12. The search box opens, with "something differently" in it and selected.

@rfindler can you try doing those same steps and report which results are different?

samth avatar Nov 12 '25 17:11 samth

Here's what I just did, with chrome on this github page (on Linux): [ ... ] @rfindler can you try doing those same steps and report which results are different?

Using Firefox on macOS, steps 5, 8, 12 were the only differences and they differed only in that the search bar always contained "shell", never changing (although I did cmd-f, not control-f; control-f advances the insertion point). I even did an initial cmd-f and erased the word "shell" but it reappeared.

Maybe this is a platform-specific convention?

rfindler avatar Nov 12 '25 19:11 rfindler

Maybe this is a platform-specific convention?

I was nerd-sniped into trawling through the Firefox source to check... Yes, indeed it is a platform-specific convention.

Firefox (and presumably other apps) are following macOS conventions, which seem to be that Cmd-F does not prefill the selection. At least in Firefox, Cmd-E is an additional macOS shortcut that does prefill the selection. I believe that on macOS, Cmd-E in many apps also sends the selection to a different global "pasteboard" so that whatever you search for appears in find bars across all applications. (I am currently on Linux at the moment, so can't confirm directly.)

As for where this is all documented by Apple... It feels like one of those things that appeared with the dawn of Mac OS X, and then it has gotten a bit lost over the decades, so I'll leave that step for someone else. 😇

jryans avatar Nov 12 '25 20:11 jryans

At least in Firefox, Cmd-E is an additional macOS shortcut that does prefill the selection.

Disappointingly, all cmd- shortcuts have long been used by DrRacket. This one is show/hide the interactions window :sadface:

rfindler avatar Nov 12 '25 21:11 rfindler

I was nerd-sniped into trawling through the Firefox source to check...

Thank you!

rfindler avatar Nov 12 '25 21:11 rfindler