Skip to content

Vim zt / scrollCursorTop doesn't take sticky_scroll into account #48864

@thomasheartman

Description

@thomasheartman

Reproduction steps

  1. Activate vim mode and sticky_scroll.
  2. Use a file that has a nested header structure. For instance, this markdown content:
# Header level 1

## Header level 2

### Header level 3

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. 
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. 
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  1. Move the cursor to the first line of content on level three ("Lorem ipsum ...")
  2. Invoke scroll cursor top (z t)

Current vs. Expected behavior

Current behavior:

When pressing z t, the current line is scrolled to the top of the entire screen content, disregarding the sticky headers. This causes your cursor to disappear and can be disorienting. It also means that the line that you're on, which you probably meant to use as a reference, is hidden by the sticky header.

Before pressing:

Image

After:

Image

The relative line numbers in this screenie shows you exactly what's happened: I can move my cursor up 2 lines to reach the previous header, or down 3 lines to reach the first visible line of text.

Expected:

The z t action should take sticky headers into consideration, such that the line is scrolled to the top of the "effective" text area. It'd look like this:

Image

Workaround and additional bug?

Moving your cursor does seem to expose it in most cases, but not always. For instance, if you place the cursor on the last line of the text ("Excepteur ...") and invoke the command, then the text content and the current level header disappears completely:

Before:

Image

After:

Image

Notice that the "Header level 3" has also been swallowed, although the breadcrumbs indicate that it should be there.

Now if I move my cursor once to the right (such that it moves, which appears to cause a recalculation), I get this:

Image

And only when I move it another step, is the current line finally revealed.

Image

Zed version and system specs

Zed: v0.223.2+preview.146.16e7dc6cfdc74af3d80fab913a694b757c3a3349 (Zed Preview)
OS: macOS 26.2
Memory: 48 GiB
Architecture: aarch64

Attach Zed log file

Zed.log

Relevant Zed settings

settings.json
{
  "sticky_scroll": {
    "enabled": true,
  },
  "vim_mode": true,
}

Relevant Keymap

keymap.json

(for AI issues) Model provider details

No response

If you are using WSL on Windows, what flavor of Linux are you using?

None

Metadata

Metadata

Labels

area:parity/vimFeedback for Vim parity featuresfrequency:uncommonBugs that happen for a small subset of users, special configurations, rare circumstances, etcpriority:P3Papercuts, minor issues with a clear workaround, cosmetic bugsstate:reproducibleVerified steps to reproduce included and someone on the team managed to reproduce

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions