Subject: bug#59902: 30.0.50; Image overlay is not updated until the cursor moves to the overlay

From: Ihor Radchenko <[email-masked]>
Date: Thu, 08 Dec 2022 11:52:49 +0000

Eli Zaretskii <[email-masked]> writes:

>> 3. Open the following org file
>>    #+begin_src sh :results graphics file :file /tmp/colour.png
>>    convert -size 300x300 xc:#002b36 /tmp/colour.png
>>    #+end_src
> ...
> Is the "convert" part in step 3 necessary to reproduce this?  If so,
> it's a huge turn-off for me, because I don't have, and won't have,
> ImageMagick installed, or anything similar to it.  So someone else
> will have to investigate this in that case, sorry.

It is not. Anything generating an image of known size will do.
The original report is in
https://list.orgmode.org/87wn7287n2.fsf@localhost/T/#mda89a57883b92c8b48ad6c4aec9e111c131efe92

You can try the following:

#+begin_src sh :results graphics file :file /tmp/colour.png
true
#+end_src

and then change to

#+begin_src sh :results graphics file :file /tmp/colour2.png
true
#+end_src

The images are attached.

>> If I step through the code inserting the image overlays, the wrong (not
>> updated) overlay appears in `org-display-inline-images':
>
> Where is this code through which you are stepping?

`org-display-inline-images'

>>     (let ((ov (make-overlay
>> 	       (org-element-property :begin link)
>> 	       (progn
>> 		 (goto-char
>> 		  (org-element-property :end link))
>> 		 (skip-chars-backward " \t")
>> 		 (point)))))
>>       (overlay-put ov 'display image) ;; <- the updated image is correctly displayed
>>       (overlay-put ov 'face 'default) ;; <- un-updated image is displayed until we move cursor to the overlay
>
> And if you switch the order of the above two lines?

Ain't helping.

> Anyway, it is not reliable to try to deduce what happens when stepping
> through the code if the problem is relied to cursor motion or
> redisplay, because Edebug changes all of that in radical ways.

I use debug-on-entry. Probably not much different though.

> Finally, a stab in the dark: the fact that the problem disappears when
> you move the cursor might mean that a call to 'redisplay' (or some
> other trigger for redisplay to know stuff has changed) is missing
> somewhere.

Nope. When I move the cursor away, the erroneous image is displayed again.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>