Eglot: fix relative position of coinciding inlay hint overlays (bug#64101)

Only seems to happen on certain platforms, like Mac OS.  Reason
unknown reason so far, but this defensive fix seems safe.

* lisp/progmodes/eglot.el (eglot--update-hints-1): Explicitly put
priority in inlay hint overalys.
This commit is contained in:
João Távora 2023-06-17 15:25:30 +01:00
parent aad7d68164
commit 3d930b928f

View file

@ -3644,8 +3644,9 @@ If NOERROR, return predicate, else erroring function."
(if peg-after-p (if peg-after-p
(make-overlay (point) (1+ (point)) nil t) (make-overlay (point) (1+ (point)) nil t)
(make-overlay (1- (point)) (point) nil nil nil))) (make-overlay (1- (point)) (point) nil nil nil)))
(do-it (label lpad rpad firstp) (do-it (label lpad rpad i)
(let* ((tweak-cursor-p (and firstp peg-after-p)) (let* ((firstp (zerop i))
(tweak-cursor-p (and firstp peg-after-p))
(ov (make-ov)) (ov (make-ov))
(text (concat lpad label rpad))) (text (concat lpad label rpad)))
(when tweak-cursor-p (put-text-property 0 1 'cursor 1 text)) (when tweak-cursor-p (put-text-property 0 1 'cursor 1 text))
@ -3656,17 +3657,18 @@ If NOERROR, return predicate, else erroring function."
(1 'eglot-type-hint-face) (1 'eglot-type-hint-face)
(2 'eglot-parameter-hint-face) (2 'eglot-parameter-hint-face)
(_ 'eglot-inlay-hint-face)))) (_ 'eglot-inlay-hint-face))))
(overlay-put ov 'priority i)
(overlay-put ov 'eglot--inlay-hint t) (overlay-put ov 'eglot--inlay-hint t)
(overlay-put ov 'evaporate t) (overlay-put ov 'evaporate t)
(overlay-put ov 'eglot--overlay t)))) (overlay-put ov 'eglot--overlay t))))
(if (stringp label) (do-it label left-pad right-pad t) (if (stringp label) (do-it label left-pad right-pad 0)
(cl-loop (cl-loop
for i from 0 for ldetail across label for i from 0 for ldetail across label
do (eglot--dbind ((InlayHintLabelPart) value) ldetail do (eglot--dbind ((InlayHintLabelPart) value) ldetail
(do-it value (do-it value
(and (zerop i) left-pad) (and (zerop i) left-pad)
(and (= i (1- (length label))) right-pad) (and (= i (1- (length label))) right-pad)
(zerop i)))))))))) i)))))))))
(jsonrpc-async-request (jsonrpc-async-request
(eglot--current-server-or-lose) (eglot--current-server-or-lose)
:textDocument/inlayHint :textDocument/inlayHint