Skip to content

CodeMirror: make Cmd-f trigger search globally

Administrator requested to merge og/cm-trigger-search into main

Created by: oleggromov

Description

As we're approaching shipping CodeMirror-based blob view for everyone, we need to take care of Cmd/Ctrl-F behaviour. This diff adds it:

  • as a global keyboard shortcut to Layout - theoretically, it should trigger search everywhere in the app, when the focus isn't hijacked and code mirror blob view is visible
  • to the SearchInput, as it has it's own hotkey handling - and we're triggering the CodeMirror search instead

Whenever search triggers, I am actually pressing Cmd-F:

https://user-images.githubusercontent.com/2196347/186660156-43a7e00a-5c2b-4ec8-8d9c-f35e61498abf.mov

Test plan

  1. Run the app locally
  2. Set enableCodeMirrorFileView to true in settings
  3. Check that with the focus inside the codemirror view, inside the search bar, or anywhere on the page Cmd-F triggers blob view search
  4. Check that outside the page with the blob view, it triggers browser's native search (unless hijacked by some other component)
  5. Toggle the setting off and check that the search isn't broken

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading