VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.97k stars 1.32k forks source link

<Backspace> while typing ex command deletes text in file #5584

Closed bowernite closed 4 years ago

bowernite commented 4 years ago

Describe the bug When typing an ex (:<...>) command, hitting backspace deletes text before the cursor instead of the text in the command I'm typing

To Reproduce Steps to reproduce the behavior:

  1. Open a file
  2. Put cursor somewhere near some text
  3. Go into normal mode
  4. Type :jumpt (typo'd jumps)
  5. Hit backspace

Expected behavior The command should now read :jump, and the text in the file should remain unchanged

Actual behavior The command still reads :jumpt, and the character before the cursor in the file is deleted.

Screenshots Recording: https://streamable.com/okvwb6

Environment (please complete the following information):

Additional context I disabled all my remappings to see if it was related, but the bug persisted.

J-Fields commented 4 years ago

Does this always happen or just sometimes? Can you go into VSCode's keyboard shortcuts and show all the mappings you have for backspace? Like this: image

bowernite commented 4 years ago

AFAIK, it happens always. I reloaded the window and tried multiple files, and it still seems to happen.

Here are my keybindings:

image

J-Fields commented 4 years ago

This one's your issue (notice it says "User" on the right?) Right click and reset the keybinding and it should work image

bowernite commented 4 years ago

Ah, you're totally right. This override was to enable "hungry/smart backspace" functionality I have in Vim when editing.

In case anyone else runs into this, the fix is to have the following overrides in keybindings.json:

  // Cancel the original vim backspace
  {
    "key": "backspace",
    "command": "-extension.vim_backspace",
    "when": "editorTextFocus && vim.active && !inDebugRepl"
  },
  // Enable the vim backspace only in search mode or ex mode
  {
    "key": "backspace",
    "command": "extension.vim_backspace",
    "when": "editorTextFocus && vim.active && !inDebugRepl && (vim.mode == 'SearchInProgressMode' || vim.mode == 'CommandlineInProgress'"
  }

Appreciate you looking into this @J-Fields 🙂