Subject: 30.0.50; eglot-execute doesn't support ExecuteCommandParams
From: Troy Brown <[email-masked]>
To: [email-masked]
Date: Tue, 18 Jun 2024 23:24:04 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

With the deprecation of eglot-execute-command and its referral to
eglot-execute, it would seem that eglot-execute should support the
same command and arguments to send the workspace/executeCommand
request to the server.  Unfortunately, this doesn't seem to work as
expected.  I would have expected the following to work:

(eglot-execute (eglot-current-server) '(:command "my-command"))

The reason this doesn't work is because within eglot-execute, the use
of eglot--dcase is configured to only match Command or CodeAction.
Command requires that there be a "title" parameter, but this doesn't
exist in the workspace/executeCommand request.  In fact, if the above
"eglot-execute" example is changed to add a ":title" parameter, it
will erroneously send a workspace/executeCommand with a title
parameter.

The following example can be used to illustrate that the Command
interface (which is intended for code actions, not for sending an
executeCommand) doesn't match for this simple case:

(condition-case err
    (eglot--dcase '(:command "my-command")
      (((Command)) (message "Matched command")))
  (error
   (message "%s" (cdr err))))

It appears that an ExecuteCommandParams interface should be added to
eglot--lsp-interface-alist and that a matcher for ExecuteCommandParams
should be added to the eglot--dcase in eglot-execute.  Additionally,
the Command matcher should be changed to not send the "title"
parameter in the subsequent workspace/executeCommand request.