VSCodeVim / VSCodeVim/Vim

Cursor jumps to the beginning of the file after switching from another one

Open
#8,200 33 comments 61 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug
Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Describe the bug
Sometimes, after switching from one file to another (through tabs), pressing a key makes the cursor jump to the beginning of the file.

To Reproduce
I haven't found yet what's triggering the issue. However, once it happens, it can be reproduced like this:

  1. One a file editor, move away from the beginning of the file (row 0, column 0, if you are there), either with the keyboard or with the mouse. For example, press j to move down one line.
  2. Switch to another file tab with the keyboard or mouse.
  3. Switch back to the previous file.
  4. Pressing any key (Esc included) but modifiers (Ctrl, Alt...) jumps to the beginning.
  5. Closing and reopening the file fixes it.

Expected behavior
The cursor should remain in the same position.

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.24.3
  • VSCode version: 1.74.2
  • OS: Linux

Additional context
This issue appeared after the upgrade to VS Code 1.74, so it may be related to #8157, although a file affected by the former might not be by the latter.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the tab-switching sequence described in the issue on the stated VS Code and VsCodeVim versions. Trace the extension's handling of editor changes, cursor restoration, and key events to identify why the first key resets the cursor; done means the cursor remains in its prior position after switching tabs and the regression is covered by a test.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.