From: João Távora Date: Thu, 27 Apr 2023 19:51:07 +0000 (+0100) Subject: Eglot: fix edge case when deleting inlay hint overlays X-Git-Tag: emacs-29.0.91~89 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=941ef044f2e0607bcaa537fbb56790a512c38782;p=emacs.git 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. --- 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." :success-fn (lambda (hints) (eglot--when-live-buffer buf (eglot--widening - (remove-overlays from to 'eglot--inlay-hint t) + ;; Overlays ending right at FROM with an + ;; `after-string' property logically belong to + ;; the (FROM TO) region. Likewise, such + ;; overlays ending at TO don't logically belong + ;; to it. + (dolist (o (overlays-in (1- from) to)) + (when (and (overlay-get o 'eglot--inlay-hint) + (cond ((eq (overlay-end o) from) + (overlay-get o 'after-string)) + ((eq (overlay-end o) to) + (overlay-get o 'before-string)) + (t))) + (delete-overlay o))) (mapc paint-hint hints)))) :deferred 'eglot--update-hints-1)))