[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master af1fe69f05d: Eglot: beware activation in fundamental-mode

From: João Távora
Subject: master af1fe69f05d: Eglot: beware activation in fundamental-mode
Date: Thu, 14 Dec 2023 13:05:33 -0500 (EST)

branch: master
commit af1fe69f05d803a6958f9d8a045d1013e2ce785c
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Eglot: beware activation in fundamental-mode
    In the specific situation of visiting a buffer via M-. with
    eglot-extend-to-xref set to t, it was found that buffer was first
    visited in fundamental mode, running after-change-major-mode-hook, and
    then again in the proper major mode for the file.  The call to
    eglot-current-server of the first visit returned non-nil which cause
    two didOpen notifications to be issued for the same file.
    Furthermore, in the first call, eglot--languageId to returned nil,
    prompting an error from servers such as rust-analyzer.
    See also: https://github.com/joaotavora/eglot/discussions/1330
    * lisp/progmodes/eglot.el (eglot-current-server): Watch out for
 lisp/progmodes/eglot.el | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 608389f1c05..84c5e6639df 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2034,13 +2034,15 @@ Use `eglot-managed-p' to determine if current buffer is 
   "Return logical Eglot server for current buffer, nil if none."
   (setq eglot--cached-server
         (or eglot--cached-server
-            (cl-find-if #'eglot--languageId
-                        (gethash (eglot--current-project)
-                                 eglot--servers-by-project))
-            (and eglot-extend-to-xref
-                 buffer-file-name
-                 (gethash (expand-file-name buffer-file-name)
-                          eglot--servers-by-xrefed-file)))))
+            (and (not (eq major-mode 'fundamental-mode)) ; gh#1330
+                 (or
+                  (cl-find-if #'eglot--languageId
+                              (gethash (eglot--current-project)
+                                       eglot--servers-by-project))
+                  (and eglot-extend-to-xref
+                       buffer-file-name
+                       (gethash (expand-file-name buffer-file-name)
+                                eglot--servers-by-xrefed-file)))))))
 (defun eglot--current-server-or-lose ()
   "Return current logical Eglot server connection or error."

reply via email to

[Prev in Thread] Current Thread [Next in Thread]