bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62540: 30.0.50; incorrect cursor positioning after overlay when put-


From: Eli Zaretskii
Subject: bug#62540: 30.0.50; incorrect cursor positioning after overlay when put-text-property 'cursor t
Date: Thu, 30 Mar 2023 16:33:16 +0300

tags 62540 notabug
thanks

> Date: Thu, 30 Mar 2023 18:59:15 +0800
> From: Platon Pronko <platon7pronko@gmail.com>
> 
> According to documentation, if a character in the overlay text string has 
> 'cursor property set to t,
> then cursor should be shown on that character while point is in the overlay.
> 
> However, it seems that this doesn't work at the moment - cursor is still 
> shown after the overlay.
> 
> Here's a test file to reproduce the problem:
> 
> ```
> AD
> 
> (defun test-overlay-cursor (completion pt)
>    (remove-overlays)
>    (save-excursion
>      (let* ((p-completion (propertize completion 'face 'error))
>             (ov (make-overlay pt pt nil t t)))
>        ;; doesn't work, cursor is shown after overlay
>        (put-text-property 0 1 'cursor t p-completion)
>        ;; works, cursor is shown before overlay
>        ;; (put-text-property 0 1 'cursor 1 p-completion)
>        (overlay-put ov 'display "")
>        (overlay-put ov 'after-string p-completion)))
>    (goto-char 2))
> (test-overlay-cursor "BC" 2)
> 
> ```
> 
> When I run the last sexp I observe the cusor being shown after the overlay:
> 
> ABC<cursor>D
> 
> While the expected position is:
> 
> A<cursor>BCD

Your overlay is "empty": it doesn't hide any buffer text characters
from being shown on display.  So Emacs has no reason to try to display
the cursor inside the overlay text: ity could simply show the cursor
on the character at point.  If you change the make-overlay call in
your test-overlay-cursor function to say this instead:

            (ov (make-overlay pt (1+ pt) nil t t)))
                                 ^^^^^^^
then it will work as you expect.  Note that the ELisp manual
explicitly talks about "when the overlay or display string make point
not visible on display".  This doesn't happen in your case.

> Workaround is to use the integer argument instead of t.

Yes, if you must use "empty" overlays.  But that is basically a side
effect of the implementation, and you should not rely on that too
much.  Better not use "empty" overlays at all if you want to show the
cursor inside the overlay string.

This is not a bug.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]