Viewport scrolling issue with C-d/C-u

Author: theol0403Created Jul 31, 2022Updated Jan 26, 2026
Labelsbugcategory: syncpriority

I noticed that @zbw8388 made a branch on their fork that made me realize a bug I missed when merging #919 and #885 - when scrolling with C-u/C-d, the veiwport is wrong.

This is because neovim internally scrolls the content while using C-u, so that the cursor position stays the same relative to the window. However, vscode moves the cursor and does not scroll the content. This causes the viewport to be unsynced.

I can think of three solutions:

  • sync neovim scroll with vscode. This could be done with win_viewport, or winsaveview. This would also remove the need for a custom implementation of C-e/C-y/zt/zb/zz. I believe @asvetliakov said this could cause jitter, but we can try.
  • modify vscode scrolling strategy. There might be a vscode api option where moving the cursor long distances will scroll the content instead of moving the cursor
  • modify neovim scrolling strategy. Make neovim scroll how vscode does, which only scrolls the content if needed

I think the first option is ideal, if it doesn't rely on too much code.

Source: vscode-neovim/vscode-neovim