Eglot: fix setting of flymake-list-only-diagnostics (bug#59824)

When Eglot receives diagnostics for a file not yet visited in Emacs,
it stores them in flymake-list-only-diagnostics, which feed M-x
flymake-show-project-diagnostics.  If the file is eventually visited
in a buffer and Eglot starts receibing diagnostics for it, the
flymake-list-only-diagnostics database has to be updated accordingly,
since the previous diagnostics are now stale.

* lisp/progmodes/eglot.el (eglot-handle-notification): Reset
flymake-list-only-diagnostics
This commit is contained in:
João Távora 2022-12-07 11:30:34 +00:00
parent d2411615e8
commit bfc00f1c12

View file

@ -2060,9 +2060,11 @@ COMMAND is a symbol naming the command."
(t 'eglot-note)))
(mess (source code message)
(concat source (and code (format " [%s]" code)) ": " message)))
(if-let ((buffer (find-buffer-visiting (eglot--uri-to-path uri))))
(if-let* ((path (expand-file-name (eglot--uri-to-path uri)))
(buffer (find-buffer-visiting path)))
(with-current-buffer buffer
(cl-loop
initially (assoc-delete-all path flymake-list-only-diagnostics #'string=)
for diag-spec across diagnostics
collect (eglot--dbind ((Diagnostic) range code message severity source tags)
diag-spec
@ -2105,7 +2107,6 @@ COMMAND is a symbol naming the command."
(t
(setq eglot--diagnostics diags)))))
(cl-loop
with path = (expand-file-name (eglot--uri-to-path uri))
for diag-spec across diagnostics
collect (eglot--dbind ((Diagnostic) code range message severity source) diag-spec
(setq message (mess source code message))