Skip to content

[Bug] Find Widget sometimes causes editors to permanently stop responding to inputs of 'a' or 'h' #5178

@alec-mitnik

Description

@alec-mitnik

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

I am unable to reproduce this in the playground, only in my local project with the editor installed via npm and webpack. This appears to be a regression, however, as I tried reproducing it with different versions installed, and found that it's not reproduced up to version 0.52.0, and starts being reproduced in version 0.53.0 and later.

Monaco Editor Playground Code

n/a

Reproduction Steps

It's hard to pinpoint the exact steps, as I can only reproduce it in my local project, a Chrome browser extension dev tools panel that I'm developing. It's possible that it's an issue specific to a dev tools panel context. It also doesn't happen every time, but it's fairly reliable to reproduce with these steps, even with no editor features specified and a language of 'plaintext':

  1. Load the page.
  2. Within the page, cause the editor to be created dynamically.
  3. Focus the editor.
  4. Open the Find widget (Ctrl+F).
  5. Click back into the editor and attempt to type into it.

Actual (Problematic) Behavior

Most characters still get typed (or bring up the "Cannot edit in read-only editor" tooltip) as normal, but for some reason, just the letters a and h will stop producing any response from the editor. Only the lowercase characters. The uppercase ones still work as normal. Pasting the characters also works as normal. It's as if there is a keydown event listener on the editor that blocks the event if its key code is KeyA or KeyH with no modifiers.

Before opening the Find widget, these characters work as normal. But once the issue starts, then for as long as the page is loaded, all editors permanently stop responding to those key inputs, whether the Find widget stays open or not. Outside of the editor, and even for the Find widget itself, the keys continue to work as normal.

Also, it seems that if opening the Find widget the first time doesn't cause the issue, it probably won't occur at all, and I have to reload the page to try to reproduce it again.

Expected Behavior

Naturally, the a and h keys should always work as normal for the editor, and not stop working after opening the Find widget, or for any other reason.

Additional Context

A workaround is to add a keydown event listener to each created editor that stops propagation of the event if its key code is KeyA or KeyH with no modifiers, but I can't be sure of the full implications of this or if it might have unintended side effects:

editor.onKeyDown((e) => {
  const isAorH = e.keyCode === monaco.KeyCode.KeyA || e.keyCode === monaco.KeyCode.KeyH;

  if (isAorH && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey) {
    e.stopPropagation();
  }
});

Another workaround is to downgrade to version 0.52.0 or earlier.

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