redhat-developer / quarkus-ls

Language server for Quarkus tooling
Eclipse Public License 2.0
44 stars 15 forks source link

Prevent resolving code actions that run commands #823

Closed datho7561 closed 1 year ago

datho7561 commented 1 year ago

Some clients, like VS Code, will attempt to resolve a code action if edit is missing, even if a command is provided. In order to prevent this from happening, pass an empty WorkspaceEdit object as the edit for code actions that run commands.

Fixes redhat-developer/vscode-quarkus#598

Signed-off-by: David Thompson davthomp@redhat.com

angelozerr commented 1 year ago

Is it a proper fix? I suggest that you explain the usecase (code action without edit but just with command) in https://github.com/microsoft/vscode-languageserver-node/issues to know if we need to set an empty workspace edit.

My fear is that some LSP client could throw an error if WorkspaceEdit has empty changes.

datho7561 commented 1 year ago

I opened https://github.com/microsoft/vscode-languageserver-node/issues/1216. See the other issue I linked there; it looks like this behaviour is intentional, but I would like a more concrete confirmation.

datho7561 commented 1 year ago

According to https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspaceEdit, changes is allowed to be empty. If we want to prevent the client from attempting to resolve the WorkspaceEdit, we can just send an empty WorkspaceEdit ({}).

datho7561 commented 1 year ago

tests are flaky ;_;

datho7561 commented 1 year ago

See https://github.com/redhat-developer/quarkus-ls/issues/809 to track the flaky tests

datho7561 commented 1 year ago

@angelozerr @JessicaJHee what do you think about merging this PR? I can't reproduce the test failures reliably on my computer.

angelozerr commented 1 year ago

Many thanks @datho7561 !