Skip to content
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

Fix pixel-scroll-precision-mode when point is on a blank line #1926

Merged
merged 1 commit into from
Aug 10, 2024

Conversation

Stebalien
Copy link
Contributor

@Stebalien Stebalien commented Jul 27, 2024

When in the point is on a blank line in normal state, scrolling down with pixel-scroll-precision-mode enabled "sticks" because Evil ends up invoking line-move in the post-command-hook. line-move resets vscroll to 0, which undoes the scroll if we scrolled less than a line.

Specifically, evil-normal-post-command calls evil-adjust-cursor which calls evil-move-end-of-line which calls move-end-of-line, which finally calls line-move.

This change avoids this issue by avoiding evil-move-end-of-line entirely, instead using bolp to check if we're already at the beginning of the line.

(note: I'm not sure if there were subtle reasons for calling evil-move-end-of-line here)

Upstream bug report: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72323. But Evil probably shouldn't be calling line-move here anyways.

Copy link
Collaborator

@axelf4 axelf4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for looking into this. I cannot think of anything important the evil-move-end-of-line call is doing, with the preceding (eolp) check (added by commit 907e7aa).

See: #1778

On a broader note, why does save-excursion not restore vscroll? Would that not alleviate this particular issue?

evil-common.el Outdated Show resolved Hide resolved
@Stebalien
Copy link
Contributor Author

On a broader note, why does save-excursion not restore vscroll? Would that not alleviate this particular issue?

save-excursion doesn't affect scrolling, just point. E.g., (save-excursion (set-window-start nil 0) will scroll to the top of the buffer, leaving point where it was.

When in the point is on a blank line in normal state, scrolling down
with `pixel-scroll-precision-mode` enabled "sticks" because Evil ends up
invoking `line-move` in the `post-command-hook`. `line-move` resets
vscroll to 0, which undoes the scroll if we scrolled less than a line.

Specifically, `evil-normal-post-command` calls `evil-adjust-cursor`
which calls `evil-move-end-of-line` which calls `move-end-of-line`,
which finally calls `line-move`.

This change avoids this issue by removing the call to `evil-move-end-of-line`
entirely, instead relying on the `bolp` call in `evil-move-cursor-back`.
@axelf4 axelf4 merged commit 5db0bdc into emacs-evil:master Aug 10, 2024
12 checks passed
@Stebalien Stebalien deleted the steb/fix-pixel-scrolling branch August 10, 2024 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants