From: Troy Brown <brownts@troybrown.dev>
To: "João Távora" <joaotavora@gmail.com>
Cc: Jeremy Bryant <jb@jeremybryant.net>, 71642@debbugs.gnu.org
Subject: bug#71642: 30.0.50; eglot-execute doesn't support ExecuteCommandParams
Date: Fri, 21 Jun 2024 08:14:02 -0400 [thread overview]
Message-ID: <CABvCZ40PrJ6XK26wMmPUEFtHO-k7i41Bbn1iwjEe91TcJWE39A@mail.gmail.com> (raw)
In-Reply-To: <CALDnm52HBHu-ifPgFHfxinB=KGaetuoVobM4WVyVx+0JBnb8_g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1233 bytes --]
On Thu, Jun 20, 2024 at 5:46 AM João Távora <joaotavora@gmail.com> wrote:
>
> On closer analysis the only confusing thing is that the spec
> encourages clients to call textDocument/executeCommand with
> illegal ExecuteCommandParams objects that contain an extraneous
> 'title'
>
> Most servers apparently don't care, but Eglot is doing this and
> it's a subtle bug.
>
> I think the right thing to do is to have Command _and_
> ExecuteCommandParams in the matcher.
>
Thanks for the explanation.
> I've done a tweak to your patch. See after my sig. It's untested, so
> please have a look. If you can, test, add more comments, change the order
> if indeed it's needed. You can also change the implementation if you think
> the recursiveness makes it more confusing.
>
I've updated the patch based on your suggestions. I've tested all
invocations of executeCommand through Command, ExecuteCommandParams
and CodeAction and they all appear to be working as expected now. I
think the recursion is fine, it's simple and elegant. With regards to
the order, you are correct, since the command in CodeAction isn't a
string, it's not a problem. I was previously erroneously only testing
with a string.
[-- Attachment #2: 0001-Eglot-Fix-command-execution-bug-71642.patch --]
[-- Type: text/x-patch, Size: 2504 bytes --]
From 963e5c975f89d9c6111902694ac51facaf7fc2b8 Mon Sep 17 00:00:00 2001
From: Troy Brown <brownts@troybrown.dev>
Date: Wed, 19 Jun 2024 20:14:07 -0400
Subject: [PATCH] Eglot: Fix command execution (bug#71642)
* lisp/progmodes/eglot.el (eglot--lsp-interface-alist): Add
ExecuteCommandParams interface.
(eglot--execute): Fix handling of Command and CodeAction and add
ExecuteCommandParams.
Copyright-paperwork-exempt: yes
---
lisp/progmodes/eglot.el | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 03da5c7b22a..df4cbe50dc0 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -624,6 +624,7 @@ eglot--uri-path-allowed-chars
:command :data :tags))
(Diagnostic (:range :message) (:severity :code :source :relatedInformation :codeDescription :tags))
(DocumentHighlight (:range) (:kind))
+ (ExecuteCommandParams ((:command . string)) (:arguments))
(FileSystemWatcher (:globPattern) (:kind))
(Hover (:contents) (:range))
(InitializeResult (:capabilities) (:serverInfo))
@@ -884,17 +885,25 @@ eglot-execute-command
(cl-defgeneric eglot-execute (server action)
"Ask SERVER to execute ACTION.
-ACTION is an LSP object of either `CodeAction' or `Command' type."
+ACTION is an LSP `CodeAction', `Command' or `ExecuteCommandParams'
+object."
(:method
(server action) "Default implementation."
(eglot--dcase action
- (((Command)) (eglot--request server :workspace/executeCommand action))
+ (((Command))
+ ;; Convert to ExecuteCommandParams and recurse (bug#71642)
+ (cl-remf action :title)
+ (eglot-execute server action))
+ (((ExecuteCommandParams))
+ (eglot--request server :workspace/executeCommand action))
(((CodeAction) edit command data)
(if (and (null edit) (null command) data
(eglot-server-capable :codeActionProvider :resolveProvider))
(eglot-execute server (eglot--request server :codeAction/resolve action))
(when edit (eglot--apply-workspace-edit edit this-command))
- (when command (eglot--request server :workspace/executeCommand command)))))))
+ (when command
+ ;; Recursive call with what must be a Command object (bug#71642)
+ (eglot-execute server command)))))))
(cl-defgeneric eglot-initialization-options (server)
"JSON object to send under `initializationOptions'."
--
2.37.1
next prev parent reply other threads:[~2024-06-21 12:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 3:24 bug#71642: 30.0.50; eglot-execute doesn't support ExecuteCommandParams Troy Brown
2024-06-19 21:19 ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-06-19 22:26 ` João Távora
2024-06-20 3:55 ` Troy Brown
2024-06-20 9:46 ` João Távora
2024-06-21 12:14 ` Troy Brown [this message]
2024-06-21 13:51 ` João Távora
2024-06-22 8:44 ` João Távora
2024-06-22 9:48 ` Eli Zaretskii
2024-06-23 14:27 ` Troy Brown
2024-06-23 14:35 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABvCZ40PrJ6XK26wMmPUEFtHO-k7i41Bbn1iwjEe91TcJWE39A@mail.gmail.com \
--to=brownts@troybrown.dev \
--cc=71642@debbugs.gnu.org \
--cc=jb@jeremybryant.net \
--cc=joaotavora@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.