Subject: bug#69972: 29.1; Unexpected behavior when scrolling images

From: Joseph Turner <[email-masked]>
Date: Mon, 25 Mar 2024 12:43:39 -0700

Eli Zaretskii <[email-masked]> writes:

>> From: Joseph Turner <[email-masked]>
>> Cc: [email-masked]
>> Date: Sun, 24 Mar 2024 18:06:44 -0700
>>
>> 1. "M-: (scroll-up) RET" (repeatedly)
>> 2. C-v (repeatedly)
>> 3. <wheel-down> (repeatedly)
>>
>> With all three methods, at first Emacs gradually scrolls the image, but
>> then when I reach the bottom of the image, the image disappears entirely
>> as Emacs scrolls past it all at once.
>
> Why is that a problem?  The default Emacs scrolling commands don't
> guarantee smooth constant-rate scrolling, they guarantee only that you
> get to see all the portions of the image, without missing any.  So
> when you get to the end of the image, there's a heuristic that decides
> whether we can scroll past the image, and that is what you see.
>
> I see no bug here.

With pixel-scroll-precision-mode enabled and at least one character after
the image, I am able to smoothly scroll around the image.

(with-current-buffer (get-buffer-create "*test-scroll-image*")
  (erase-buffer)
  (insert-image (create-image "splash.png" nil nil :scale 10))
  (insert " ") ;; There must be some text after the image
  (goto-char (point-min))
  (pixel-scroll-precision-mode 1)
  (pop-to-buffer (current-buffer)))

However, if the window is scrolled to the right, then it is impossible
to scroll down:

(with-current-buffer (get-buffer-create "*test-scroll-image*")
  (erase-buffer)
  (insert-image (create-image "splash.png" nil nil :scale 10))
  (insert-char 8203)
  (goto-char (point-min))
  (pixel-scroll-precision-mode 1)
  (pop-to-buffer (current-buffer))
  (set-window-hscroll (get-buffer-window) 1)) ;; Image scrolled to right

In this buffer, if I attempt to scroll down with the mouse wheel, I
immediately get "End of buffer" error and the image does not move.

Thank you!

Joseph