Vim icon indicating copy to clipboard operation
Vim copied to clipboard

For some symbols, `gd` jumps to a wrong location several seconds after jumping to the correct definition.

Open js-shi opened this issue 7 years ago • 4 comments

Describe the bug For some symbols, 'gd' jumps to the end of the file containing the real definition. Following c-o will jump back to the beginning of the file.

To Reproduce Steps to reproduce the behavior:

  1. Navigate to a symbol (I'm browsing C++ code) and press 'gd' to jump to the definition.
  2. Cursor will jump to the definition correctly.
  3. Wait for about 3 seconds without any further inputs, the cursor will then jump to the end of the file.
  4. Press c-o will jump to the beginning of the file.
  5. Press c-o again will jump back to the end of the file.
  6. Press c-o the third time will jump back to where 'gd' is issued.

Expected behavior F12 and Alt+Left Arrow works correctly. 'gd' and c-o should jump to the correct locations.

Screenshots If applicable, add screenshots to help explain your problem. If remapping-related, please attach log output: https://github.com/VSCodeVim/Vim#debugging-remappings.

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.8.1
  • VSCode version: 1.35.0 - insider / 1.34.0
  • OS: Win10 64

Additional context Add any other context about the problem here.

Here is the log in the developers console when I hit the bug: [Extension Host] ModeHandler: debug: handling key=g. workbench.main.js:238 [Extension Host] Remapper: debug: trying to find matching remap. keys=g. mode=Normal. keybindings=normalModeKeyBindingsMap. workbench.main.js:238 [Extension Host] Remapper: debug: trying to find matching remap. keys=g. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap. workbench.main.js:238 [Extension Host] ModeHandler: debug: handling key=d. workbench.main.js:238 [Extension Host] Remapper: debug: trying to find matching remap. keys=d. mode=Normal. keybindings=normalModeKeyBindingsMap. workbench.main.js:238 [Extension Host] Remapper: debug: trying to find matching remap. keys=d. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap. workbench.main.js:238 [Extension Host] VimState: warn: invalid cursor position. [ [2555, 56] | [2555, 56]]. workbench.main.js:238 [Extension Host] VimState: warn: invalid cursor start position. [2555, 56]. workbench.main.js:238 [Extension Host] ModeHandler: debug: handling key=. workbench.main.js:238 [Extension Host] Remapper: debug: trying to find matching remap. keys=. mode=Normal. keybindings=normalModeKeyBindingsMap. workbench.main.js:238 [Extension Host] Remapper: debug: trying to find matching remap. keys=. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap. workbench.main.js:238 [Extension Host] ModeHandler: debug: handling key=. workbench.main.js:238 [Extension Host] Remapper: debug: trying to find matching remap. keys=. mode=Normal. keybindings=normalModeKeyBindingsMap. workbench.main.js:238 [Extension Host] Remapper: debug: trying to find matching remap. keys=. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap. workbench.main.js:238 [Extension Host] VimState: warn: invalid cursor stop position. [2555, 56]. workbench.main.js:238 [Extension Host] VimState: warn: invalid cursor start position. [2555, 56]. workbench.main.js:238 [Extension Host] ModeHandler: debug: handling key=. workbench.main.js:238 [Extension Host] Remapper: debug: trying to find matching remap. keys=. mode=Normal. keybindings=normalModeKeyBindingsMap. workbench.main.js:238 [Extension Host] Remapper: debug: trying to find matching remap. keys=. mode=Normal. keybindings=normalModeKeyBindingsNonRecursiveMap. workbench.main.js:238 [Extension Host] getCursorsAfterSync: warn: getCursorsAfterSync: selection not updated within 0ms.

[2555,56] is acutally the line and column where I pressed 'gd'. The first warning is triggered about 3 seconds after the cursor jumps to the correct location.

js-shi avatar May 29 '19 09:05 js-shi

I thing this is a "codelen" problem. I prevented this problem by closeing codelen . setting.json "editor.codeLens": false, See the codelen feature in release notes: 1.34.0

And I found all move 'j', 'k', 'c-d' etc will be obvious delayed after 'gd'. The native go-to-definition(f12) has not this trouble. Hope to improve this so that I don't have to wait a few milliseconds before moving.

WangRongda avatar May 30 '19 09:05 WangRongda

I'm also seeing this behaviour. disabling code lens fixes it for me but I use code lens all the time so I'd rather not disable it. i was able to solve the problem by mapping over the gd command, (and adding a gp command for fun):

    {
      "before": ["g", "p"],
      "commands": ["editor.action.peekDefinition"]
    },
    {
      "before": ["g", "d"],
      "commands": ["editor.action.revealDefinition"]
    },

sentilesdal avatar Jun 07 '19 21:06 sentilesdal

This work-around, rebinding gd in the proposed way seems to work fine for me, too.

DanielFabian avatar Jun 21 '19 08:06 DanielFabian

Same issue, but unfortunately, rebinding gd doesn't work for me. Does anyone have any other workaround?

nerdmax avatar Jul 08 '19 00:07 nerdmax