Subject: bug#46316: 27.1; wrong horizontal scroll with truncate-lines value t

From: [email-masked]
Date: Mon, 08 Feb 2021 00:28:57 +0900

Eli Zaretskii <[email-masked]> writes:

> tags 46316 notabug
> thanks
>
>> From: [email-masked]
>> Date: Fri, 05 Feb 2021 14:08:06 +0900
>> 
>> 
>> (1) When isearch fails after last match
>> Evaluate the form below and type 'C-s a C-s', then emacs messages
>> 'Failing I-search: a' and the buffer scrolls back left and the current
>> point is out of the window.
>> Type C-s again, and overwrapped search succeeds at the same point,
>> but the matched point is still out of the window.
>> 
>>   (let ((buf (generate-new-buffer "tmp")))
>>     (switch-to-buffer buf)
>>     (setq truncate-lines t)
>>     (dotimes (i 100) (insert (format "%d\n" i)))
>>     (insert-char ?x 200)
>>     (insert ?a)
>>     (goto-char (point-min)))
>> 
>> (2) When image-toggle-display
>> Evaluate the form below, then the SVG image is displayed.
>> Type 'C-c C-c' to view the source text and type 'C-c C-c' again to view
>> the image, then the buffer keeps scrolled right and the image is hidden
>> out of the window.
>> Type C-a and the image is shown, type 'C-c C-c' to view the source text
>> again, then the buffer keeps scrolled left and the current point is out
>> of the window.
>> 
>>   (let ((buf (generate-new-buffer "tmp"))
>>         (svg "<svg width=\"80\" height=\"80\" version=\"1.1\"\
>>    xmlns=\"http://www.w3.org/2000/svg\"\
>>    xmlns:xlink=\"http://www.w3.org/1999/xlink\">\
>>    <rect width=\"80\" height=\"80\" x=\"0\" y=\"0\" fill=\"blue\"></rect>\
>>   </svg>"))
>>     (switch-to-buffer buf)
>>     (setq truncate-lines t)
>>     (insert svg)
>>     (image-mode))
>
> I don't think this behavior is a bug.  We only change the hscroll of a
> window when point moves, and in these two scenarios it doesn't move.
> I see no reason to assume that the user will necessarily want to have
> the window scroll, instead of keeping it at its current horizontal
> scroll.

In the case of isearch, the hscroll is changed without point motion
when isearch fails.

In the case of image-toggle-display, the hscroll is changed without
point motion when typing 'C-c C-c' for the first time.