Support workspace/executeCommand for actions' data (#26239)

Closes https://github.com/zed-industries/zed/issues/16746
Part of https://github.com/zed-extensions/deno/issues/2

Changes the action-related code so, that

* `lsp::Command` as actions are supported, if server replies with them
* actions with commands are filtered out based on servers'
`executeCommandOptions`
(https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#executeCommandOptions)
— commands that are not listed won't be executed and the corresponding
actions will be hidden in Zed

Release Notes:

- Added support of `workspace/executeCommand` for actions' data

---------

Co-authored-by: Peter Tripp <petertripp@gmail.com>
This commit is contained in:
Kirill Bulatov 2025-03-06 23:26:46 +02:00 committed by GitHub
parent 97c0a0a86e
commit af5af9d7c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 217 additions and 87 deletions

View file

@ -2951,6 +2951,10 @@ async fn test_apply_code_actions_with_commands(cx: &mut gpui::TestAppContext) {
..lsp::CodeActionOptions::default()
},
)),
execute_command_provider: Some(lsp::ExecuteCommandOptions {
commands: vec!["_the/command".to_string()],
..lsp::ExecuteCommandOptions::default()
}),
..lsp::ServerCapabilities::default()
},
..FakeLspAdapter::default()
@ -5372,7 +5376,7 @@ async fn test_code_actions_only_kinds(cx: &mut gpui::TestAppContext) {
let code_actions = code_actions_task.await.unwrap();
assert_eq!(code_actions.len(), 1);
assert_eq!(
code_actions[0].lsp_action.kind,
code_actions[0].lsp_action.action_kind(),
Some(CodeActionKind::SOURCE_ORGANIZE_IMPORTS)
);
}
@ -5529,7 +5533,7 @@ async fn test_multiple_language_server_actions(cx: &mut gpui::TestAppContext) {
.await
.unwrap()
.into_iter()
.map(|code_action| code_action.lsp_action.title)
.map(|code_action| code_action.lsp_action.title().to_owned())
.sorted()
.collect::<Vec<_>>(),
"Should receive code actions responses from all related servers with hover capabilities"