Skip to content

vim: Don't push scrolls to nav history #30345

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

dovakin0007
Copy link
Contributor

@dovakin0007 dovakin0007 commented May 9, 2025

Closes #17592

Release Notes:

  • Added Don't push to nav history while scrolling in Vim mode
Untitled.video.-.Made.with.Clipchamp.mp4

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label May 9, 2025
@zed-industries-bot
Copy link

zed-industries-bot commented May 9, 2025

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against e6c6792

@dovakin0007 dovakin0007 changed the title vim: don't push scrolls to nav history vim: Don't push scrolls to nav history May 9, 2025
@dovakin0007
Copy link
Contributor Author

@ConradIrwin please do let me know what are the changes can be done and whether the given approach is the right one thank you

@timmclean
Copy link

I was looking into jumplist issues in Zed this week with @danielcressman so I thought I'd chime in here.

There are a bunch of bugs related to the jumplist in vim mode. The overall problem is that there is a mismatch between how vim manages its jumplist vs how Zed in vim mode manages its jumplist. I think all of these bugs could be resolved at the same time by aligning Zed's vim mode behaviour to match vim.

In Zed, it seems that any navigation action can count as a "jump":

However, Zed requires that the navigation change the cursor position by at least MIN_NAVIGATION_HISTORY_ROW_DELTA lines, which is hardcoded to 10 in the codebase. This prevents e.g. single line movements from adding to the jumplist.

In vim, whether a navigation is a "jump" is determined entirely based on the type of movement. This means that even a single line move can count as a jump if it is the right type of motion, while a 100-line move may not count as a jump if it is not the right type of motion.

In other words, there are 2 types of problems right now with Zed's jumplist: situations where it adds to the jumplist but shouldn't, and situations where it doesn't add to the jumplist but it should (e.g. #30183).

In my view, Zed should match vim's jumplist behaviour by default when Zed is in vim mode. This would mean eliminating the use of MIN_NAVIGATION_HISTORY_ROW_DELTA (while in vim mode, at least), and adding entries to the jumplist only when the navigation is of the right type.

@dovakin0007
Copy link
Contributor Author

I was looking into jumplist issues in Zed this week with @danielcressman so I thought I'd chime in here.

There are a bunch of bugs related to the jumplist in vim mode. The overall problem is that there is a mismatch between how vim manages its jumplist vs how Zed in vim mode manages its jumplist. I think all of these bugs could be resolved at the same time by aligning Zed's vim mode behaviour to match vim.

In Zed, it seems that any navigation action can count as a "jump":

However, Zed requires that the navigation change the cursor position by at least MIN_NAVIGATION_HISTORY_ROW_DELTA lines, which is hardcoded to 10 in the codebase. This prevents e.g. single line movements from adding to the jumplist.

In vim, whether a navigation is a "jump" is determined entirely based on the type of movement. This means that even a single line move can count as a jump if it is the right type of motion, while a 100-line move may not count as a jump if it is not the right type of motion.

In other words, there are 2 types of problems right now with Zed's jumplist: situations where it adds to the jumplist but shouldn't, and situations where it doesn't add to the jumplist but it should (e.g. #30183).

In my view, Zed should match vim's jumplist behaviour by default when Zed is in vim mode. This would mean eliminating the use of MIN_NAVIGATION_HISTORY_ROW_DELTA (while in vim mode, at least), and adding entries to the jumplist only when the navigation is of the right type.

I have pushed the changes for these any suggestions will be really helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't push to nav history when scrolling
3 participants