From 13f439ce98c4cdd57bddfa671f071e31fa2badc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Tue, 8 Apr 2025 08:43:14 +0100 Subject: [PATCH] Eglot: check textDocument/publishDiagnostics version (bug#77588) * lisp/progmodes/eglot.el (eglot--versioned-identifier): Move up. (eglot-handle-notification textDocument/publishDiagnostics): Check eglot--versioned-identifier --- lisp/progmodes/eglot.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index c937283122e..bfa67ebfff0 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2657,9 +2657,12 @@ Value is (TRUENAME . (:uri STR)), where STR is what is sent to the server on textDocument/didOpen and similar calls. TRUENAME is the expensive cached value of `file-truename'.") +(defvar-local eglot--versioned-identifier 0) + (cl-defmethod eglot-handle-notification - (server (_method (eql textDocument/publishDiagnostics)) &key uri diagnostics - &allow-other-keys) ; FIXME: doesn't respect `eglot-strict-mode' + (server (_method (eql textDocument/publishDiagnostics)) + &key uri diagnostics version + &allow-other-keys) ; FIXME: doesn't respect `eglot-strict-mode' "Handle notification publishDiagnostics." (cl-flet ((eglot--diag-type (sev) (cond ((null sev) 'eglot-error) @@ -2681,6 +2684,8 @@ expensive cached value of `file-truename'.") (with-current-buffer buffer (cl-loop initially + (if (and version (/= version eglot--versioned-identifier)) + (cl-return)) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics)) for diag-spec across diagnostics @@ -2809,8 +2814,6 @@ Sets `eglot--TextDocumentIdentifier-cache' (which see) as a side effect." `(,truename . (:uri ,(eglot-path-to-uri truename :truenamep t)))))) (cdr eglot--TextDocumentIdentifier-cache)) -(defvar-local eglot--versioned-identifier 0) - (defun eglot--VersionedTextDocumentIdentifier () "Compute VersionedTextDocumentIdentifier object for current buffer." (append (eglot--TextDocumentIdentifier)