VSCodeVim / VSCodeVim/Vim

Extraneous downward movement with `gj`, `gk`, `g$`

Open
#8,512 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug

Visual line movement (i.e. gj, gk, g$ etc.) behaviors are broken when the cursor is placed at the end of a wrapped line that happens to be longer than the line above or below it. There will be an extraneous downward movement of 1 line, putting the cursor 1 line below its expected position.

To Reproduce

Set editor.wordWrap to bounded. Type the text below (as a single line) in VSCode. Reduce the width of the VSCode window until the visually displayed text is wrapped identically to what's shown below.

This is a piece of example text 
that is soft-wrapped to multiple 
visual lines, to demonstrate an 
issue with the plugin.

Place the cursor at the very end of the 2nd line (i.e. the space character after "multiple").

  1. Pressing gj moves the cursor to the beginning of the 4th line.
    Expected behavior: cursor moves to end of 3rd line.
  2. Pressing gk will move the cursor to the beginning of the 2nd line.
    Expected behavior: cursor moves to end of 1st line.

As for the behavior of g$:

Place the cursor at the very beginning of the 2nd line. Pressing g$ brings the cursor to the beginning of the 3rd line. Expected behavior: cursor to be moved to the end of the 2nd line. This issue was raised in #2032 back in 2017 but seems like it hasn't been addressed.

Environment:

  • Extension (VsCodeVim) version: v1.25.2
  • VSCode version: 1.80.1
  • OS: macOS Monterey 12.4 (21F79)

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

Reproduce the movement in VSCode with editor.wordWrap set to bounded, using the text and cursor positions from the issue. Trace the visual-line movement handling for gj, gk, and g$, then verify that each movement lands on the expected visual line and that the behavior is covered by regression checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
tooling
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.