mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-13 23:49:02 +00:00
Prevent stale servers when using eglot-extend-to-xref
A weak-valued hash-table is not enough to guarantee that a reference to a zombie server in eglot--servers-by-xrefed-file variable won't survive long enough to confuse the next call to eglot--current-server in some buffers. So, before this fix it was common to get "Process EGLOT ... not running" errors if some xref-extended buffers (like system libraries) were open and M-x eglot-reconnect was issued. This should be prevented now. Note however, that even after this the eglot-extend-to-xref logic is still flawed. For example, if a buffer for the xref-extended buffer happens to be already visited by the time M-. is issued to navigate to it, Eglot won't be activated. A half-decent workaround is to kill the buffer and re-visit it. * lisp/progmodes/eglot.el (eglot--servers-by-xrefed-file): Move up. (eglot--on-shutdown): Make sure to cleanup eglot--servers-by-xrefed-file.
This commit is contained in:
parent
9bf13a3fb9
commit
bbe35c280c
1 changed files with 6 additions and 3 deletions
|
@ -908,6 +908,9 @@ PRESERVE-BUFFERS as in `eglot-shutdown', which see."
|
||||||
do (with-demoted-errors "[eglot] shutdown all: %s"
|
do (with-demoted-errors "[eglot] shutdown all: %s"
|
||||||
(cl-loop for s in ss do (eglot-shutdown s nil nil preserve-buffers)))))
|
(cl-loop for s in ss do (eglot-shutdown s nil nil preserve-buffers)))))
|
||||||
|
|
||||||
|
(defvar eglot--servers-by-xrefed-file
|
||||||
|
(make-hash-table :test 'equal :weakness 'value))
|
||||||
|
|
||||||
(defun eglot--on-shutdown (server)
|
(defun eglot--on-shutdown (server)
|
||||||
"Called by jsonrpc.el when SERVER is already dead."
|
"Called by jsonrpc.el when SERVER is already dead."
|
||||||
;; Turn off `eglot--managed-mode' where appropriate.
|
;; Turn off `eglot--managed-mode' where appropriate.
|
||||||
|
@ -926,6 +929,9 @@ PRESERVE-BUFFERS as in `eglot-shutdown', which see."
|
||||||
(setf (gethash (eglot--project server) eglot--servers-by-project)
|
(setf (gethash (eglot--project server) eglot--servers-by-project)
|
||||||
(delq server
|
(delq server
|
||||||
(gethash (eglot--project server) eglot--servers-by-project)))
|
(gethash (eglot--project server) eglot--servers-by-project)))
|
||||||
|
(maphash (lambda (f s)
|
||||||
|
(when (eq s server) (remhash f eglot--servers-by-xrefed-file)))
|
||||||
|
eglot--servers-by-xrefed-file)
|
||||||
(cond ((eglot--shutdown-requested server)
|
(cond ((eglot--shutdown-requested server)
|
||||||
t)
|
t)
|
||||||
((not (eglot--inhibit-autoreconnect server))
|
((not (eglot--inhibit-autoreconnect server))
|
||||||
|
@ -1057,9 +1063,6 @@ be guessed."
|
||||||
(put 'eglot-lsp-context 'variable-documentation
|
(put 'eglot-lsp-context 'variable-documentation
|
||||||
"Dynamically non-nil when searching for projects in LSP context.")
|
"Dynamically non-nil when searching for projects in LSP context.")
|
||||||
|
|
||||||
(defvar eglot--servers-by-xrefed-file
|
|
||||||
(make-hash-table :test 'equal :weakness 'value))
|
|
||||||
|
|
||||||
(defun eglot--current-project ()
|
(defun eglot--current-project ()
|
||||||
"Return a project object for Eglot's LSP purposes.
|
"Return a project object for Eglot's LSP purposes.
|
||||||
This relies on `project-current' and thus on
|
This relies on `project-current' and thus on
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue