unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#60557: [PATCH] Fix eglot prompt when connection already exists
@ 2023-01-04 15:44 Evgeni Kolev
  2023-01-12  9:35 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Evgeni Kolev @ 2023-01-04 15:44 UTC (permalink / raw)
  To: 60557; +Cc: joaotavora

[CC-ing João Távora, author of eglot]

This patch fixes an incorrect behavior of eglot. To reproduce:
- run M-x eglot
- run M-x eglot (again)
- eglot now prompts whether to reconnect to the existing LSP
- enter "n" (for no)
- now eglot shuts down the LSP process and reconnects - this is not
correct, the expected behavior is to not reconnect

The patch is below.

commit f7626c070d4bd63fab1df33153ab9deaec0a3f7b (HEAD -> master)
Author: Evgeni Kolev <evgenysw@gmail.com>
Date:   Wed Jan 4 17:36:30 2023 +0200

    Fix eglot prompt when connection already exists

    When M-x eglot is executed twice, the second time it prompts whether
    to reconnect. Answering "no" was not working correctly - the existing
    LSP process was still reconnected.

    This behavior is fixed, answering "no" results in keeping the existing
    connection.

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 6d192d9b333..7ac123f3c09 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -1116,10 +1116,9 @@ eglot
   (setq managed-major-mode (eglot--ensure-list managed-major-mode))
   (let* ((current-server (eglot-current-server))
          (live-p (and current-server (jsonrpc-running-p current-server))))
-    (if (and live-p
-             interactive
-             (y-or-n-p "[eglot] Live process found, reconnect instead? "))
-        (eglot-reconnect current-server interactive)
+    (if (and live-p interactive)
+        (when (y-or-n-p "[eglot] Live process found, reconnect instead? ")
+          (eglot-reconnect current-server interactive))
       (when live-p (ignore-errors (eglot-shutdown current-server)))
       (eglot--connect managed-major-mode project class contact language-id))))





^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-01-18  5:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04 15:44 bug#60557: [PATCH] Fix eglot prompt when connection already exists Evgeni Kolev
2023-01-12  9:35 ` Eli Zaretskii
2023-01-12 10:53   ` João Távora
2023-01-14  6:02     ` Evgeni Kolev
2023-01-14 17:22       ` João Távora
2023-01-16 11:53       ` João Távora
2023-01-16 14:08         ` Eli Zaretskii
2023-01-16 14:15         ` Eli Zaretskii
2023-01-16 14:42           ` João Távora
2023-01-16 14:54             ` Eli Zaretskii
2023-01-18  5:58               ` Evgeni Kolev

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).