]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: don't paint hints outside requested region (bug#61812)
authorJoão Távora <joaotavora@gmail.com>
Mon, 27 Feb 2023 14:23:35 +0000 (14:23 +0000)
committerJoão Távora <joaotavora@gmail.com>
Mon, 27 Feb 2023 14:23:53 +0000 (14:23 +0000)
* lisp/progmodes/eglot.el (eglot--lambda): Add cl-block.
(eglot--update-hints-1): Return early if hint is outside the
requested inlay hint range.

lisp/progmodes/eglot.el

index 719b3abe4cb8ce01216e985ec7313dda964ac12d..ef758371c16ca6684e668c9f42364ecd2b42ac4b 100644 (file)
@@ -641,7 +641,7 @@ Honor `eglot-strict-mode'."
 Honor `eglot-strict-mode'."
   (declare (indent 1) (debug (sexp &rest form)))
   (let ((e (cl-gensym "jsonrpc-lambda-elem")))
-    `(lambda (,e) (eglot--dbind ,cl-lambda-list ,e ,@body))))
+    `(lambda (,e) (cl-block nil (eglot--dbind ,cl-lambda-list ,e ,@body)))))
 
 (cl-defmacro eglot--dcase (obj &rest clauses)
   "Like `pcase', but for the LSP object OBJ.
@@ -3595,6 +3595,7 @@ If NOERROR, return predicate, else erroring function."
          (paint-hint
           (eglot--lambda ((InlayHint) position kind label paddingLeft paddingRight)
             (goto-char (eglot--lsp-position-to-point position))
+            (when (or (> (point) to) (< (point) from)) (cl-return))
             (let ((ov (make-overlay (point) (point)))
                   (left-pad (and paddingLeft (not (memq (char-before) '(32 9)))))
                   (right-pad (and paddingRight (not (memq (char-after) '(32 9)))))