Vim icon indicating copy to clipboard operation
Vim copied to clipboard

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

Open js-shi opened this issue 7 years ago • 18 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

js-shi avatar Dec 19 '18 07:12 js-shi

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.

GrandZhuo avatar Dec 25 '18 14:12 GrandZhuo

same issues

wYuanHpp avatar Dec 29 '18 07:12 wYuanHpp

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

Filed https://github.com/Microsoft/vscode/issues/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 avatar Dec 29 '18 10:12 jpoon

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

jpoon avatar Jan 17 '19 06:01 jpoon

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.

eddiewang avatar Feb 07 '19 14:02 eddiewang

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

solomonchild avatar Feb 12 '19 13:02 solomonchild

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.

emmanueltouzery avatar Mar 19 '19 09:03 emmanueltouzery

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

ihaveadrame avatar Jan 04 '20 05:01 ihaveadrame

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.)

troygibb avatar Jan 23 '20 17:01 troygibb

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

drewthor avatar Jan 23 '20 21:01 drewthor

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

jmaha avatar Feb 12 '20 21:02 jmaha

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?

kortina avatar Feb 18 '20 07:02 kortina

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

jiapengwen avatar Feb 20 '20 02:02 jiapengwen

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 avatar Feb 25 '20 06:02 kortina

@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.

J-Fields avatar Feb 25 '20 06:02 J-Fields

Same here

ocodista avatar Nov 01 '21 23:11 ocodista

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.

YHM404 avatar Jul 24 '23 10:07 YHM404

I remapped VSCodeVim to VSCode navigate commands and it's been working great.

"vim.normalModeKeyBindingsNonRecursive": [
    {
        "before": [ "<C-o>" ],
        "commands": [{"command": "workbench.action.navigateBack"}]
    },
    {
        "before": [ "<C-i>" ],
        "commands": [{"command": "workbench.action.navigateForward"}]
    }
]

jimmyyentran avatar Jan 03 '25 08:01 jimmyyentran