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

Jumping to Previous Position After Pressing a Key #9195

Open
zshaian opened this issue Aug 10, 2024 · 8 comments · May be fixed by #9286
Open

Jumping to Previous Position After Pressing a Key #9195

zshaian opened this issue Aug 10, 2024 · 8 comments · May be fixed by #9286
Labels

Comments

@zshaian
Copy link

zshaian commented Aug 10, 2024

Describe the bug
When searching for a symbol in VS Code, after finding the symbol and navigating to it, pressing any key on the keyboard causes the cursor to jump back to its previous position.

To Reproduce
Steps to reproduce the behavior:

  1. Toggle the search symbol in VS code ( Ctrl + Shift + o ) or (Ctrl + p ) and then type "@"
  2. start searching for a symbol that you want to go to
  3. click the symbol or press enter
  4. start pressing any key

Expected behavior
After navigating to the symbol I want to go to, the cursor should not jump back to its previous position after pressing any key.

Environment

  • Extension (VsCodeVim) version: v1.27.3
  • VSCode version: 1.92.1
  • OS: Windows 10 ( Windows_NT x64 10.0.19045)

Additional context
This issue is not limited to searching for a symbol. If I also search for a word by pressing (Ctrl + F) and then navigate to that word, pressing any key causes the cursor to jump back to its previous position. This bug does not always occur, sometimes it doesn’t happen, and I’m still unsure what triggers it.

@xiangfu1003
Copy link

I have the same issue,
performance varies in different files, some files must appear, while others do not have this issue。
hope this problem can be resolved soon

@zxch3n
Copy link

zxch3n commented Aug 18, 2024

gd is used to go to the definition in my config. After press i to enter the insert mode, it jumps back to the previous position.

CleanShot.2024-08-18.at.20.16.18.mp4

@sguillia
Copy link

sguillia commented Sep 4, 2024

This bug exists for more than a year and was reported here: microsoft/vscode#177598

But it was closed after being identified as related to VSCodeVim.

If there are any pointers or guidance on how to address this, please let me know—I'm happy to contribute if I'm able.

This bug annoys me every single day.

@qazxcdswe123
Copy link

qazxcdswe123 commented Sep 30, 2024

This is because <C-o> uses custom jump list and track jump(goto) command that is issued by vim only. So goto issued by mouse click is not tracked.
To fix this simply add this to settings.json

    {
      "before": ["<C-o>"],
      "commands": [
        "workbench.action.navigateBack"
      ]
    },

@wolf0403
Copy link

wolf0403 commented Oct 20, 2024

Hi @qazxcdswe123 I'm slightly confused about where <C-o> come into play.
I'm having this issue with "Go to Definition" (F12) followed by vim cursor moving command (h/j/k/l)

It feels like cursor jumping from VSCode commands are not tracked by VSCodeVim - is it possible to have VSCodeVim somehow find where currently cursor is, in some circumstances, before moving cursors?

@qazxcdswe123
Copy link

Hi @qazxcdswe123 I'm slightly confused about where <C-o> come into play. I'm having this issue with "Go to Definition" (F12) followed by vim cursor moving command (h/j/k/l)

It feels like cursor jumping from VSCode commands are not tracked by VSCodeVim - is it possible to have VSCodeVim somehow find where currently cursor is, in some circumstances, before moving cursors?

  1. Use CMD+ Mouse click to jump
  2. C-o wont jump back to the correct location

As of your problem, I have no idea :(

@yuanx749
Copy link

yuanx749 commented Nov 5, 2024

I have met the same issue at times, but it seems to work fine now, except in visual mode.

@beantowel
Copy link

beantowel commented Dec 26, 2024

This is because <C-o> uses custom jump list and track jump(goto) command that is issued by vim only. So goto issued by mouse click is not tracked. To fix this simply add this to settings.json

    {
      "before": ["<C-o>"],
      "commands": [
        "workbench.action.navigateBack"
      ]
    },

In my "vim.handleKeys" setting, "<C-o>" is disabled, but the problem still rises

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants