Skip to content

cancelSelection interferes with extension API registerCommand("type") #331580

Description

Does this issue occur when all extensions are disabled?: No, it's a bug with the extension API itself

  • VS Code Version: 1.135.0-insider (Universal)
  • OS Version: Darwin arm64 25.4.0

Hello, I'm reporting a bug I've noticed where calling cancelSelection interferes with extensions that register the "type" command. Normally extensions can register "type" to intercept all inputs:

subscription = vscode.commands.registerCommand("type", onType)

This is useful for Vim-style extensions which want to override regular typed letters like "a", "b", "c". Typing those letters are instead intercepted by the onType listener, and don't actually type letters.

However, I noticed that when I trigger a "cancelSelection" command, the next typed letter will actually get typed, somehow bypassing the "type" register command:

Screen.Recording.2026-08-18.at.4.21.42.PM.mp4

In the above recording I have a "type" command registered, configured so that typing the letter "a" will trigger the "cancelSelection" command, and typing the letter "j" will trigger the "cursorDown" command.

When I press "j" I would expect the cursor to move down one row.

Instead, when I press "j" it removes most of the section I had previously highlighted, only keeping a couple letters. Then it adds "jj".

Some extra information:

  • This issue began occurring sometime between 2026-01-01 and 2026-04-23 on stable
  • My extension I used to reproduce this (bmalehorn.vimspired) hasn't been updated in 3 years, so it's not a change in the extension. You can view the extension source here
  • It's possible this is a regression in the extension API, and I'd be fine with a workaround my extension can use
  • Canceling selection by pressing Escape does not reproduce the issue (so, what's the difference between Escape and cancelSelection?)
  • This doesn't occur on reverse selection (selecting from right to left)
  • This doesn't occur on multiline selections
  • The amount of text remaining (above, only 1 character remained) is not consistently 1 character, it's a variable amount between 0 and the whole line
  • Different keys (a, j) and different commands (cursorDown) still reproduce the issue

Steps to Reproduce:

  1. Install the extension bmalehorn.vimspired
  2. Set your vscode config to:
{
  "vimspired.keybindings": {
    "a": "cancelSelection",
    "j": "cursorDown",
  },
}
  1. in a file, highlight one line from left to right
  2. press "a"
  3. press "j"

Expected: the cursor moves down 1 row, no text is modified.
Actual: the previously-highlighted portion is partially deleted and "jj" is added to the end.

Metadata

Metadata

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