]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: check textDocument/publishDiagnostics version (bug#77588)
authorJoão Távora <joaotavora@gmail.com>
Tue, 8 Apr 2025 07:43:14 +0000 (08:43 +0100)
committerEshel Yaron <me@eshelyaron.com>
Tue, 8 Apr 2025 19:41:46 +0000 (21:41 +0200)
* lisp/progmodes/eglot.el (eglot--versioned-identifier): Move up.
(eglot-handle-notification textDocument/publishDiagnostics): Check
eglot--versioned-identifier

(cherry picked from commit 13f439ce98c4cdd57bddfa671f071e31fa2badc6)

lisp/progmodes/eglot.el

index 2cb8245c0fc441f4d16cf2eb3da6716e4f6e1806..6965c386e8dd261202af1c2f12ef863354f200fc 100644 (file)
@@ -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)