From: João Távora Date: Tue, 8 Apr 2025 07:43:14 +0000 (+0100) Subject: Eglot: check textDocument/publishDiagnostics version (bug#77588) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bba7fb8eb0d2a12a62998aa0e2b8c888adb1c0f9;p=emacs.git 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 (cherry picked from commit 13f439ce98c4cdd57bddfa671f071e31fa2badc6) --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 2cb8245c0fc..6965c386e8d 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -2693,9 +2693,12 @@ expensive cached value of `file-truename'.") (1+ (plist-get (plist-get range :end) :line))))))) (cons beg end))) +(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) @@ -2717,6 +2720,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 @@ -2829,8 +2834,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)