fix(pdf-roll): forget the displayed pages of every window, not one - #367
Open
alberti42 wants to merge 1 commit into
Open
fix(pdf-roll): forget the displayed pages of every window, not one#367alberti42 wants to merge 1 commit into
alberti42 wants to merge 1 commit into
Conversation
`pdf-roll-initialize' and the disable branch of `pdf-view-roll-minor-mode'
clear the `displayed-pages' of a window with
(image-mode-window-put 'displayed-pages nil)
which reaches the selected window only. That is not necessarily a window
showing the buffer -- a revert arriving from a process sentinel or a timer
runs with whatever window happened to be selected -- and it is never the
other windows showing it. Those keep a list naming pages the buffer may
no longer hold an overlay for, either because the overlays were replaced
or because the document is shorter than it was, and
`pdf-roll-undisplay-pages' is then handed a page it cannot find.
With three windows recorded, the old call leaves two of them untouched:
((t) (window-a 3 4) (window-b 5 6))
`pdf-roll--forget-displayed-pages' walks the winprops instead. It walks a
copy, because `image-mode-window-put' can add the `t' entry to the alist.
One test in `test/pdf-roll-test.el'.
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-initializeand the disable branch ofpdf-view-roll-minor-modeboth forget which pages a window has displayed like this:With no window argument that reaches the selected window only. With three windows recorded it leaves two of them untouched:
Why it matters
The selected window is not necessarily a window showing the buffer.
pdf-roll-initializeis an:afteradvice onrevert-buffer-function, and a revert that arrives from a process sentinel or a timer — AUCTeX reverting a recompiled document,auto-revert-mode, a file notification — runs with whatever window happened to be selected at that moment. It is also never the other windows showing the same buffer.Those windows keep a
displayed-pageslist naming pages the buffer may no longer hold an overlay for, either because the overlays were replaced or because the new document is shorter than the old one.pdf-roll-pre-redisplaythen hands the difference between that list and the pages it just drew topdf-roll-undisplay-pages, which looks each one up.The fix
pdf-roll--forget-displayed-pageswalks the winprops instead of touching one window. It walks a copy, becauseimage-mode-window-putcan add thetentry toimage-mode-winprops-alistwhile the loop is running.One test in
test/pdf-roll-test.elcovers it.Priority
Lower than #361, #362 and #364. It needs the same document in more than one window together with a revert, and #362 guards
pdf-roll-undisplay-pagesagainst the consequence, so with that PR applied this is a correctness fix rather than a visible one.Conflict
Conflicts with #362 in
lisp/pdf-roll.el: both changepdf-roll-initialize. Happy to rebase on top of it — the resolution is to call the new helper in place of the single-windowimage-mode-window-putinside that PR's structure.