branch: externals/eglot
commit 4b453dcde984881e648f1c17c2fc7b147fce7f5b
Author: João Távora <[email protected]>
Commit: João Távora <[email protected]>
Fix #389: avoid double shutdowns and simplify shutdown logic
* eglot.el (eglot-shutdown): Don't turn off eglot--managed-mode here.
(eglot--on-shutdown): Rather here, but without autoshutdown.
(eglot--managed-mode): Don't check eglot--shutdown-requested.
---
eglot.el | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/eglot.el b/eglot.el
index d1ff7da..e952b91 100644
--- a/eglot.el
+++ b/eglot.el
@@ -599,9 +599,6 @@ SERVER. ."
;; this one is supposed to always fail, because it asks the
;; server to exit itself. Hence ignore-errors.
(ignore-errors (jsonrpc-request server :exit nil :timeout 1)))
- ;; Turn off `eglot--managed-mode' where appropriate.
- (dolist (buffer (eglot--managed-buffers server))
- (eglot--with-live-buffer buffer (eglot--managed-mode-off)))
;; Now ask jsonrpc.el to shut down the server (which under normal
;; conditions should return immediately).
(jsonrpc-shutdown server (not preserve-buffers))
@@ -611,7 +608,9 @@ SERVER. ."
"Called by jsonrpc.el when SERVER is already dead."
;; Turn off `eglot--managed-mode' where appropriate.
(dolist (buffer (eglot--managed-buffers server))
- (eglot--with-live-buffer buffer (eglot--managed-mode-off)))
+ (let (;; Avoid duplicate shutdowns (github#389)
+ (eglot-autoshutdown nil))
+ (eglot--with-live-buffer buffer (eglot--managed-mode-off))))
;; Kill any expensive watches
(maphash (lambda (_id watches)
(mapcar #'file-notify-rm-watch watches))
@@ -1289,8 +1288,7 @@ For example, to keep your Company customization use
(setf (eglot--managed-buffers server)
(delq (current-buffer) (eglot--managed-buffers server)))
(when (and eglot-autoshutdown
- (not (eglot--shutdown-requested server))
- (not (eglot--managed-buffers server)))
+ (null (eglot--managed-buffers server)))
(eglot-shutdown server)))))))
(defun eglot--managed-mode-off ()