CTRL+F find should automatically put hilighted/selected text in searchbox
https://github.com/user-attachments/assets/b39826b3-b8ea-4017-8457-d48b21111ebf
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?
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.
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.
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.
Are there any popular browsers and IDEs that don't do this? In my experience, it's been universal.
Oh, I see. Thanks for explaining. Seems worth experimenting with.
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.
I tried some macOS programs too. These do it:
- Chrome
- VS Code
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".
Here's what I just did, with chrome on this github page (on Linux):
- Hit ctrl-f. The search text box is empty.
- Close the search box.
- Select "The selected text".
- Press ctrl-f.
- The search box opens. It contains "The selected text", which is also itself selected in that search box.
- Select "the search bar". (note that the search box is still open but not selected)
- Press ctrl-f.
- The content of the search box changes to "the search bar" and it is selected.
- Close the search box.
- Select "something differently".
- Press ctrl-f.
- 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?
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?
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. 😇
At least in Firefox, Cmd-E is an additional macOS shortcut that does prefill the selection.
Disappointingly, all cmd-
I was nerd-sniped into trawling through the Firefox source to check...
Thank you!