aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoão Távora2023-04-27 20:51:07 +0100
committerJoão Távora2023-04-28 00:39:08 +0100
commit941ef044f2e0607bcaa537fbb56790a512c38782 (patch)
treed37cfa638670f34af66345a65cb95613203ed2c3
parenta365984d9e167c4d71a2a44a1abb4710765f460f (diff)
downloademacs-941ef044f2e0607bcaa537fbb56790a512c38782.tar.gz
emacs-941ef044f2e0607bcaa537fbb56790a512c38782.zip
Eglot: fix edge case when deleting inlay hint overlays
When asked to update hints in a region (FROM TO), eglot--update-hints-1 first deletes the existing hints. It must however take care to delete all overlays that logically belong to the region, even if they don't physically belong to it, e.g. inlay overlays spanning (FROM-1 FROM) and having a 'after-string' property. * lisp/progmodes/eglot.el (eglot--update-hints-1): Fix edge case.
-rw-r--r--lisp/progmodes/eglot.el14
1 files changed, 13 insertions, 1 deletions
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index ed554087084..0fab8db0e83 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3664,7 +3664,19 @@ If NOERROR, return predicate, else erroring function."
3664 :success-fn (lambda (hints) 3664 :success-fn (lambda (hints)
3665 (eglot--when-live-buffer buf 3665 (eglot--when-live-buffer buf
3666 (eglot--widening 3666 (eglot--widening
3667 (remove-overlays from to 'eglot--inlay-hint t) 3667 ;; Overlays ending right at FROM with an
3668 ;; `after-string' property logically belong to
3669 ;; the (FROM TO) region. Likewise, such
3670 ;; overlays ending at TO don't logically belong
3671 ;; to it.
3672 (dolist (o (overlays-in (1- from) to))
3673 (when (and (overlay-get o 'eglot--inlay-hint)
3674 (cond ((eq (overlay-end o) from)
3675 (overlay-get o 'after-string))
3676 ((eq (overlay-end o) to)
3677 (overlay-get o 'before-string))
3678 (t)))
3679 (delete-overlay o)))
3668 (mapc paint-hint hints)))) 3680 (mapc paint-hint hints))))
3669 :deferred 'eglot--update-hints-1))) 3681 :deferred 'eglot--update-hints-1)))
3670 3682