fix(pdf-roll): send a negative scroll argument the other way, once - #366
Open
alberti42 wants to merge 1 commit into
Open
fix(pdf-roll): send a negative scroll argument the other way, once#366alberti42 wants to merge 1 commit into
alberti42 wants to merge 1 commit into
Conversation
Both scroll commands start with
(setq n (* (or n 1) (if pixels 1 (frame-char-height))))
(setq window (or window (selected-window)))
(when (> 0 n) (pdf-roll-scroll-backward (- n) window))
which is wrong in three ways. The `when' does not return, so the body
runs as well and the window is scrolled twice. N has already been
multiplied by `frame-char-height' by then, and PIXELS is not passed on,
so the callee multiplies it a second time. And in
`pdf-roll-scroll-backward' the call goes to `pdf-roll-scroll-backward',
which is the direction it was asked to reverse.
Dispatch on the sign before scaling, and return. Starting from page 10
at vscroll 500 with `frame-char-height' 23, a negative argument now
matches the positive call in the other direction:
before after expected
(pdf-roll-scroll-forward -3) 844 431 431 = (backward 3)
(pdf-roll-scroll-backward -3) 982 569 569 = (forward 3)
Reachable interactively as `C-u -3 C-n' and through the `S-<prior>' and
`S-<next>' screen commands with a negative prefix.
Same shape as the dispatch in vedang#338, so it should not get in the way there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happens
pdf-roll-scroll-forwardandpdf-roll-scroll-backwardboth mishandle a negative argument. Starting from page 4 at vscroll 500, withframe-char-height23, on a 16 page document:(pdf-roll-scroll-forward -3 win)(pdf-roll-scroll-backward 3 win)(pdf-roll-scroll-backward -3 win)(pdf-roll-scroll-forward 3 win)Reachable interactively as
C-u -3 C-norC-u -3 <down>, sincepdf-view-roll-minor-moderemaps the line commands onto these two, and throughpdf-roll-scroll-screen-forwardandpdf-roll-scroll-screen-backwardwith a negative prefix, which pass a negative pixel count straight down.Why
Both functions start like this:
which is wrong in three ways.
The
whendoes not return, so after delegating, the body runs as well and the window is scrolled a second time in the original direction.nhas already been multiplied byframe-char-heightwhen the call is made, andpixelsis not passed on, so the callee multiplies it again. That is where 3144 comes from rather than 431: the larger the pages, the further it goes.And in
pdf-roll-scroll-backwardthe call goes topdf-roll-scroll-backward— the direction it was asked to reverse.The fix
Dispatch on the sign before scaling, and return:
This is the same shape as the dispatch in #338, so it should not get in the way there. The rest of both functions is unchanged; the diff looks larger than it is because the body moves into the
elsebranch.Priority
Lower than #361, #362 and #364 — it needs a deliberate negative prefix argument, so it is not something a normal binding reaches.
Conflict
Conflicts with #364 in
lisp/pdf-roll.el: that PR changes the line immediately after this one in both functions. I am happy to rebase this on top of whichever of the two you take first — the resolution is to keep #364's starting position inside thisif.