Skip to content

Make snippet editor search persistent and safe #515

Description

@code-snippets-bot

Problem

The CodeMirror search dialog opened by Ctrl+F / Cmd+F is non-persistent. Pressing Enter closes the dialog and returns focus to the snippet editor, including when there are no matches. Users may then accidentally type, paste, or press Enter in their code.

Forum report: https://wordpress.org/support/topic/issues-caused-by-the-built-in-search-behavior/

Current behaviour

Code Snippets already loads CodeMirror's persistent findPersistent command on Alt+F. Ctrl+F / Cmd+F still use CodeMirror's default non-persistent find command.

Acceptance criteria

  • Map Ctrl+F and Cmd+F to CodeMirror's existing findPersistent command.
  • Keep focus in the search input after Enter.
  • Escape or an explicit close action returns focus to the code editor.
  • Make the search field sufficiently wide for typical code queries.
  • Show an accessible, visible no-results state.
  • Verify Default, Vim, Emacs, and Sublime Text keymaps do not regress.
  • Verify Tab inserts or indents immediately under the Default keymap.

Scope

Reuse CodeMirror's search API. Do not build a separate search engine unless its API cannot meet these requirements.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions