Vim: Cursor jumps up to the beginning of a file after saving.

Created on 2 Feb 2019  路  17Comments  路  Source: VSCodeVim/Vim

Good day everyone,

FOREWORD: This is happening only when working with Go files and only when VIM plugin is installed.

Cursor jumps to the "import" line if I move the cursor after saving and if I move again it goes down a few lines; I'm not even sure it tries to return to its previous place, just jumps like a half screen down. This happens only when the OUTPUT tab is open (on the right side) with "Go Tests" printing its usual output. I guess it's interfering with the editor window somehow. First thing that comes to my mind is that the cursor position is reset on keypress after saving.

I've noticed this only yesterday as I've moved back to Linux(Ubuntu 18.10) from MacOS and I've copied only few of my snippets and user settings. Btw, I've worked on this Linux machine for quite a while before spending some time on MacOS, and everything worked perfectly.

I've tested by disabling, reinstalling, deleting all configuration. (including ~/.config/CODE), and also changed to all available go formatters but the problem still persists unfortunately.

kinbug

Most helpful comment

I've followed your example and downgraded gradually down to 1.0.2 (apparently things got broken above this version). Everything works fine atm, waiting for an update.

P.S. you guys are doing an amazing job and how you've managed to embed VIM so gently, and how it interoperates with VSCODE... thanks!

AND huge thanks to the GO extension team for creating such a superb Golang support in VSCODE (since I know you're following this too ^^) One big THANKS to both teams :)

All 17 comments

I am experiencing the same issue: VScode+Go+Vim plugins cause the cursor to relocate on save. I can confirm that the behavior change occurred between vim plugin versions 1.0.2 (expected behavior after save) and 1.0.3+ (cursor relocating). For now I've downgraded my version of the vim plugin as a workaround. (From the vscode extensions list, click on the Vim settings "gear" icon, and select "Install Another Version...")

EDIT: using Go plugin version 0.8, vscode version 1.30.2 on Mac OS X.
AFAICT, the Go plugin 0.8 was released Dec 12, 2018, and the 1.30.2 release of VScode was released around early Jan 2019. And, the behavior change on save occurred more recently, within the last few weeks. There have been numerous updates to the vim plugin in that time.

I've followed your example and downgraded gradually down to 1.0.2 (apparently things got broken above this version). Everything works fine atm, waiting for an update.

P.S. you guys are doing an amazing job and how you've managed to embed VIM so gently, and how it interoperates with VSCODE... thanks!

AND huge thanks to the GO extension team for creating such a superb Golang support in VSCODE (since I know you're following this too ^^) One big THANKS to both teams :)

I have this exact same issue.

Thanks to @agubarev I downgraded to 1.0.2 (cmd-alt-p -> Extensions: Install Specific Version of Extension -> Vim -> 1.0.2)
Also add

"extensions.autoUpdate": false,

Or you'll get the latest version.

Thanks to @agubarev I downgraded to 1.0.2

Nah, thanks to @stephen-soltesz

Can't repro... either with :w or a ctrl+s. The cursor stays where it should be.

Nothing is apparent looking at the diff between the two versions. https://github.com/VSCodeVim/Vim/compare/v1.0.2...v1.0.3

@jpoon can you confirm, what plugins are enabled during your test? There may be a subtle interaction between the Go & Vim plugins. I'm sure I or @agubarev or @noseglid could provide additional diagnostic information if we knew what would be helpful to provide. Does the vim plugin have a "debug" logging option, for example?

Does the vim plugin have a "debug" logging option, for example?

See the *.debug options. https://github.com/VSCodeVim/Vim#vscodevim-settings

I've enabled the debug option, and all output I get is;

[Extension Host] ModeHandler: debug: handling key=j.
console.ts:134 [Extension Host] Remapper: debug: trying to find matching remap. keys=j. mode=Normal. keybindings=normalModeKeyBindingsMap.
console.ts:134 [Extension Host] Remapper: debug: trying to find matching remap. keys=j. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap.
2console.ts:134 [Extension Host] Remapper: verbose: key=j. keySlice=j.

Here's a gif outlining how it goes. After the test has been run I need to move the cursor before the jump actually happens. So I press j or k and then it jump to "near the top". It seems a bit random where it actually ends up.
jumpy

Awesome! This is resolved for me by 1.0.8 - Thanks for the very quick response!

I still have this problem with vim plugin 1.10.0, go plugin 0.11.4, and vs 1.37.1

same problem happen to me on, vs 1.37.1, extensions: go plugin 0.11.4, live server 5.6.1, material icon theme 3.9.0

same problem VS 1.38.1 go plugin 0.11.6

I'm having the same problem still VSCodeVIM version - 1.11.0, Go version 0.11.7. Happens on Windows, doesn't happen on Linux.

Yes, very annoying... Workaround is mouse click in the place of cursor after save....

Still happening with ctrl+s shortcut. But not with :w in vim mode.

Still happening with CTRL+S on Windows 10, VS Code 1.44.2, go 1.14.2 & VSCodeVim 1.13.1

same problem on windows
vscode-1.44.2, vim extension-1.13.1, go extension-0.14.1
Thanks @stephen-soltesz. Downgrade vim to 1.0.2 works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

stefanoio picture stefanoio  路  3Comments

typeoneerror picture typeoneerror  路  3Comments

waltiam picture waltiam  路  3Comments

spinningarrow picture spinningarrow  路  3Comments