VSCodeVim/Vim

<c-o> jumps back to wrong location after 'gd'

js-shi opened this issue · 17 comments

Describe the bug
When navigating some C++ source code, I found C-o sometimes cannot jump back to the correct position before 'gd'. On the other hand, Alt + Left Arrow can correctly jump back to the call site.

To Reproduce
Steps to reproduce the behavior:

Just use 'gd' to perform go to symbol on the call site and to jump back. In most cases, it works great but sometimes not. The bug can be reproduced constantly but I cannot figure out the pattern yet.

Expected behavior
Jump back to the correct position.

  • Extension (VsCodeVim) version: 0.17.0
  • VSCode version: 1.30.0

I have encountered the same problem recently, but I don't remember which version started to have the problem.
And I found that if I use "gd" jump to the definition in the same file, I can't jump back to the correct position using . But it works if I jump to the definition in different files.
I hope to fix this bug as soon as possible.

same issues

jpoon commented

Thanks @GrandZhuo for describing the behaviour. Really helped track down the issue.

Filed microsoft/vscode#65809 against VS Code. The API call to go to the definition returns immediately. As a result, when we save the jump location, we are saving the old location before the cursor actually moves to the new location.

Adding a 1s sleep seems to do the trick.

jpoon commented

We can get rid of our hack following https://github.com/Microsoft/vscode/milestone/83.

I'm currently on v1.31.0 and experiencing the same issue. Just to confirm, when I use gd to jump to a different file, I am unable to use c-o to go back to that file.

Using c-p-p is my current workaround for this.

The same behavior is observed if you Ctrl+Click instead of gd. C-o jumps to a wrong location (even if it is the same file).

Version: 1.31.0

I think this issue is still present, the bug probably should be reopened. I'm certainly having issues with C-o myself, the builtin VS code shortcut works fine though.

Now I have a similar problem,go to defined works fine but error when jumping back(ctrl + o). I found that this problem is normal in the old version, such as 1.11.3 I use now。

os: win10

Per earlier comments about the built-in VSCode shortcut working just fine-- just remap your shortcuts to use the native VSCode go back/go forward functions instead VSCodeVim. I.e. in your settings:

"vim.handleKeys": {
    "<C-o>": false
}

And then in Keyboard Shortcuts change the settings for Go Back and Go Forward to Ctrl + o and Ctrl + i respectively. (For some reason disabling vscode <C-o> screwed up the Go Forward command.)

A workaround but it's a stopgap solution because it adds more annoyances. It does not perform like vim's go back and forward commands. Instead it goes back and forward on every up and down arrow key movement as well which is a huge annoyance consistently

jmaha commented

Agreed that this should be reopened. This behavior is maddening.

I have confirmed the same issue,

  • Mac Catalina 10.15.3 (19D76)
  • VS Code Version: 1.42.1
  • vscode vim 1.12.4

I considered @troygibb's solution, but while 'Go Back' does return you correctly after 'Go To Definition,' you lose a bunch of the other cases that vscode vim jumplist handles better.

Any ideas on root cause or ETA for fix?

I have confirmed the same issue,

  • Mac Catalina 10.15.3 (19D76)
  • VS Code Version: 1.42.1
  • vscode vim 1.12.4

I considered @troygibb's solution, but while 'Go Back' does return you correctly after 'Go To Definition,' you lose a bunch of the other cases that vscode vim jumplist handles better.

Any ideas on root cause or ETA for fix?

+1, the same issue

I noticed there has not been a release to the extension since 26 Dec 2019. Does anyone know how often releases go out / when the commit that closes this would be part of the public extension?

@kortina There isn't a set release cycle. There are a few more PRs I want to merge before the next release, but it should be soon.

Same here

YHM404 commented

Per earlier comments about the built-in VSCode shortcut working just fine-- just remap your shortcuts to use the native VSCode go back/go forward functions instead VSCodeVim. I.e. in your settings:

"vim.handleKeys": {
    "<C-o>": false
}

And then in Keyboard Shortcuts change the settings for Go Back and Go Forward to Ctrl + o and Ctrl + i respectively. (For some reason disabling vscode <C-o> screwed up the Go Forward command.)

this works for me, thx.