From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Evgeni Kolev Newsgroups: gmane.emacs.bugs Subject: bug#60557: [PATCH] Fix eglot prompt when connection already exists Date: Wed, 4 Jan 2023 17:44:27 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6453"; mail-complaints-to="usenet@ciao.gmane.io" Cc: joaotavora@gmail.com To: 60557@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 04 16:46:38 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pD5yP-0001Wb-Sl for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 04 Jan 2023 16:46:37 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pD5xt-0003Xp-VH; Wed, 04 Jan 2023 10:46:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pD5xs-0003WO-Cz for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2023 10:46:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pD5xr-0003gf-0p for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2023 10:46:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pD5xq-0007jT-64 for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2023 10:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Evgeni Kolev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 04 Jan 2023 15:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 60557 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.167284710529643 (code B ref -1); Wed, 04 Jan 2023 15:46:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 4 Jan 2023 15:45:05 +0000 Original-Received: from localhost ([127.0.0.1]:49367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pD5wu-0007i3-HN for submit@debbugs.gnu.org; Wed, 04 Jan 2023 10:45:04 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:35744) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pD5ws-0007hr-6o for submit@debbugs.gnu.org; Wed, 04 Jan 2023 10:45:03 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pD5wq-0003II-9H for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2023 10:45:00 -0500 Original-Received: from mail-yw1-x1130.google.com ([2607:f8b0:4864:20::1130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pD5wm-0003EI-Qp for bug-gnu-emacs@gnu.org; Wed, 04 Jan 2023 10:44:58 -0500 Original-Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-46198b81e5eso481751317b3.4 for ; Wed, 04 Jan 2023 07:44:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jhYUibNUy6Gan+aNGz+/5VCOg1Y0TwIvuEkbO6H9b0c=; b=pV80v2cJJXBYxOrbHEH0XYtY4/F+8vYaA3Ci3WeatNB1aZRyhyWjeNxDguhfEuT0+H Pi6wlEo6ruNuWenAJ3I1BzKJm91egZ2Fb9Yn0f0znZJe0ILn8SZQGwLa5u7TIi6/mAkd 6mgwIkWXewsGaU7q0SjwdGIEWbOWQIL26jrbCKJL61LcM7xZJOdyi7A+qtZB9YjBDhj4 1ErG4M/HzFeXIzFi3qVFk/iM6pLT1lOrlgWkmnywazOGX4mVTLtLdjbubKZpRZAFFoPd P8cdLyW0jC+7KW/LZ3Zciwaz3fRy152H4NVw+pjCrCGIeY3fP2yNT+NP0TZtcTrMCPEr AQow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jhYUibNUy6Gan+aNGz+/5VCOg1Y0TwIvuEkbO6H9b0c=; b=F2Ub3e/1HeS32rHytr3UGEt1GWtPT2KkbJA/XCRYFhaUm2xmSflAQlGxQwf7cuwvuu U35bUg2/8qK3a9XEhGJfHNfWhBFdf0EcOlAs6bAZq2alqI00Z0HtQHLFvBQDRbqW6Jat +etyXf6vbrDmorXUs4JgkXrxprifBmNx5lUK0/T08VOrjtEjtq4xpUchwB8/3qLAH5Q1 me+dTlR86AJa24LoPl7pGcv69jA4KZB7auowcwIsfzHMVEEPAD8LYacZu3SFAMWlXffb DbAe+MnU5p4a581f8chjudB8nvscz7Zq56y7VarW4p/V8SMa54+73fCk4w2JyCiHrmxP 6Ygg== X-Gm-Message-State: AFqh2kqd5ZcOFXVkhErDsS4vZLMfA4NWa6tX141edSpZlNL8gjkV+P3K WSBWVHDrQHV3Fv9XJw27O48Fdabt1XVuTr1bsDkY4siWNQ0flOQe X-Google-Smtp-Source: AMrXdXuiXsSSCh1oI79FRJk3BvKyEjdWAo5K4TfRRMufsv2+4YOJL3P1sPOf4WyweQ5DUrPVMYAOY5fTMcJRawyyJpQ= X-Received: by 2002:a05:690c:80c:b0:46d:89d7:498f with SMTP id bx12-20020a05690c080c00b0046d89d7498fmr4049342ywb.461.1672847093821; Wed, 04 Jan 2023 07:44:53 -0800 (PST) Received-SPF: pass client-ip=2607:f8b0:4864:20::1130; envelope-from=evgenysw@gmail.com; helo=mail-yw1-x1130.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:252495 Archived-At: [CC-ing Jo=C3=A3o T=C3=A1vora, 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 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= ))))