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

Vim handles keystrokes in wrong sequence if Code is not responding immediately #1340

Open
rebornix opened this issue Feb 28, 2017 · 5 comments
Labels

Comments

@rebornix
Copy link
Member

vim-lag

  • Try to update Line 4466 of the action.ts of this project and you are adding a ) after }
  • Press Esc and then . quickly.
  • The content ends up with }). and the state is normal mode.

Code takes a few seconds to handle match bracket logic after you press ) so that's why the Esc doesn't immediately change the cursor style to Block real quick. However Code is sending the events with correct sequence but we didn't handle them in a good order

Code type: a
Vim Handler: a
Code type: )
Vim Handler: )
Code key: <Esc>
Code type: .
Vim handler: .
Vim handler: <Esc>
@rebornix rebornix changed the title Vim handles keystrokes in wrong sequence if Code is not responding immediately` Vim handles keystrokes in wrong sequence if Code is not responding immediately Feb 28, 2017
@johnfn
Copy link
Member

johnfn commented Mar 2, 2017

Ah, interesting, they get out of sequence.

One good way to reproduce this is to write some code that introduces a random delay before handling events.

@Chillee
Copy link
Member

Chillee commented May 8, 2017

Could this piece of code be the cause?

https://github.com/VSCodeVim/Vim/blob/master/src/actions/commands/actions.ts#L102

@Chillee
Copy link
Member

Chillee commented Jun 26, 2017

Oh shit I think I found the reason why @rebornix @johnfn @xconverge
https://github.com/VSCodeVim/Vim/blob/master/extension.ts#L357

    registerCommand(context, keybinding.command, () => handleKeyEvent(`${ bracketedKey }`));

We have a task queue that is meant to handle the above scenario. However, when we're handling special keys, we just ignore the task queue!

@rebornix
Copy link
Member Author

@Chillee very likely a good catch!

@knewter
Copy link

knewter commented Oct 18, 2018

This is the only thing I dislike about editing in vscode, but it's a huge deal for me. I very frequently run I<esc>ww or something similar to get to the second word in a line. I know it's not ideal vim golf but it's muscle memory. 80% of the time, this results in inserting the text ww at the front of the line and staying in insert mode :-\

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

No branches or pull requests

4 participants