]> git.eshelyaron.com Git - emacs.git/commit
Eglot: fix jit-lock inlay hint bugs
authorJoão Távora <joaotavora@gmail.com>
Fri, 24 Feb 2023 14:48:01 +0000 (14:48 +0000)
committerJoão Távora <joaotavora@gmail.com>
Fri, 24 Feb 2023 14:48:01 +0000 (14:48 +0000)
commit55d29c9bacb6227bc8b3a6c0dd52c7085fe63aaf
treeddfedd061784100476fdd5b84ae489c8aa34e1b4
parent5db75ec7d30d5cf5dc610382ca25bd5a5c4f8fb6
Eglot: fix jit-lock inlay hint bugs

One of the bugs was straightforward.  The timer function of
eglot--update-hints must set the correct buffer.

The other is much more odd.  When using Eglot on Emacs's own
src/coding.c, the jit-lock code starts calling its jit-functions over
and over again with the same sequence of arguments, like so:

======================================================================
1 -> (eglot--update-hints 63551 65051)
1 <- eglot--update-hints: [nil 25592 52026 4
======================================================================
1 -> (eglot--update-hints 65051 66551)
1 <- eglot--update-hints: [nil 25592 52026 4
======================================================================
1 -> (eglot--update-hints-1 63551 66551)
1 <- eglot--update-hints-1: nil
======================================================================
1 -> (eglot--update-hints 63551 65051)
1 <- eglot--update-hints: [nil 25592 52026 4
======================================================================
1 -> (eglot--update-hints 65051 66551)
1 <- eglot--update-hints: [nil 25592 52026 5
======================================================================
1 -> (eglot--update-hints-1 63551 66551)
1 <- eglot--update-hints-1: nil

This continues forever at a very fast rate and saturates the LSP
channel.

At first I thought that it was because eglot--update-hints-1 is
actually causing the buffer to be modified with overlays sometime in
the future, but it is not so!  It seems that merely calling

   (goto-char (eglot--lsp-position-to-point position))

(from the LSP request handler in eglot--update-hints-1) will cause
this bug.

* lisp/progmodes/eglot.el (eglot--update-hints): Fix bugs.
lisp/progmodes/eglot.el