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

Fix issues with keybindings when changing to an editor in different mode #3108

Merged

Conversation

shawnaxsom
Copy link
Contributor

What this PR does / why we need it:

Fix issues with keybindings when changing to an editor in different mode. This resulted in keybindings not working until changing modes again, including seeing <Tab> inserted as text in insert mode, if vscode thought we were in normal mode still.

Which issue(s) this PR fixes

fixes #3096
fixes #730
fixes microsoft/vscode#59925

Special notes for your reviewer:

I'm not exactly sure why we don't have tests between editors. It would be nice to add tests here. I know that in the onDidChangeActiveTextEditor handler we even return automatically if Globals.isTesting is true.

Anyway, there are two main changes here:

  1. "setContext vim.mode" is called when switching editor windows (previously this wasn't getting called until pressing keys in the new editor window).
  2. I also made _previousMode static, since setContext for vim.mode applies across editors (along with renaming to _lastVimModeSetForKeybindings to clarify purpose).

This resulted in keybindings not working until changing modes again, including seeing <Tab> inserted as text in insert mode, if vscode thought we were in normal mode still.
@xconverge
Copy link
Member

I had tried this optimization before and had to revert/push a new release, I dont remember why, your way looks better with the static

LGTM if it works right

@shawnaxsom
Copy link
Contributor Author

Yeah it is working in the test cases I've tried, changing tabs and opening new tabs in various mode states. This fixes the reported issue and I'm not aware of any related issues. There is an open issue with inserted with replace mode, but that isn't the same root cause as far as I can tell.

@xconverge xconverge merged commit ffebf09 into VSCodeVim:master Oct 6, 2018
@shawnaxsom shawnaxsom deleted the bugfix/keybindings-on-editor-change branch October 6, 2018 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants