Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom <Esc> key binding "jj" stoped working when entering insert mode from "cw" #3088

Closed
Confidenceman02 opened this issue Oct 3, 2018 · 7 comments · Fixed by #3090
Closed

Comments

@Confidenceman02
Copy link

Confidenceman02 commented Oct 3, 2018

Describe the bug
Leaving insert mode with a custom key binding does not work if you entered insert mode from a "cw" command.

To Reproduce
Steps to reproduce the behavior:

map "jj" to <Esc> with

 "vim.insertModeKeyBindings": [
        {
            "before": ["j", "j"],
            "after": ["<Esc>"]
        }
    ]
  1. hit "i" to enter insert mode and write some text. Press "jj" to confirm it leaves insert mode.
  2. go to the start of the text/word and hit "cw" to change the word.
  3. hit "jj"
  4. just keeps rendering the letter "j" and does not leave insert mode as it should.

Expected behavior
When entering insert mode with "cw" typing "jj", if mapped to <Esc>, should indeed exit insert mode considering it works fine when hitting "i" then hitting 'jj".

Screenshots
vscode

Environment (please complete the following information):

  • Extension Name: vim
  • Extension Version: 0.16.6
  • OS Version: Darwin x64 17.7.0
  • VSCode version: 1.27.2

Additional context

@shawnaxsom
Copy link
Contributor

shawnaxsom commented Oct 3, 2018

Thanks for the report! I was able to reproduce, and I will take a look.

This is a regression from #3081, which enabled black hole remappings by preventing use of remappings after an operator is pressed. That logic seems like it would work, except in this case the whole "ciwjj" is considered one key combination (which makes sense, as Vim would count it as one combination on e.g. undo), and therefore it sees an operator (the c key) is in play and thinks it shouldn't allow remappings.

I believe what is needed is to ensure post-operator keys don't remap only in Normal mode. I will create some unit tests for the scenarios you mention, and put up a fix PR.

@shawnaxsom
Copy link
Contributor

Bug fix PR is up. Remappings should work in this case if an operator combination results in leaving normal mode. I added a test as well to make sure we don't have future regressions.

@sarink
Copy link

sarink commented Oct 4, 2018

As a temporary workaround in the meantime, you can downgrade this extension to the previous version:

  1. Download: https://github.com/VSCodeVim/Vim/releases/download/v0.16.5/vim-0.16.5.vsix
  2. From the VSCode Command Palette (cmd+shift+P), select Extensions: Install from VSIX...
  3. Choose the old vsix file, and override the current version with the old one
  4. ciwHooray!jj

@rightaway
Copy link

@sarink When a new version is available how can I update from this custom version?

@damassi
Copy link

damassi commented Oct 5, 2018

Also curious about how to update. I'm noticing that this custom remap breaks in a few different instances, not just cw.

@shawnaxsom
Copy link
Contributor

An update is planned for tonight I heard. I'm not sure about if you install a custom version, you might have to uninstall it and reinstall from searching in the store after the update is released.

@sarink
Copy link

sarink commented Oct 5, 2018

To re-update, simply uninstall and reinstall, it's no big deal.

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

Successfully merging a pull request may close this issue.

6 participants