Allows triggering commands after an assist edit

This commit is contained in:
Jonas Schievink 2022-04-19 18:37:18 +02:00
parent e3ec87730a
commit c6ffffccbd
18 changed files with 58 additions and 16 deletions

View file

@ -318,6 +318,7 @@
"quickfix",
),
),
command: None,
edit: Some(
SnippetWorkspaceEdit {
changes: Some(

View file

@ -165,6 +165,7 @@
"quickfix",
),
),
command: None,
edit: Some(
SnippetWorkspaceEdit {
changes: Some(

View file

@ -165,6 +165,7 @@
"quickfix",
),
),
command: None,
edit: Some(
SnippetWorkspaceEdit {
changes: Some(

View file

@ -165,6 +165,7 @@
"quickfix",
),
),
command: None,
edit: Some(
SnippetWorkspaceEdit {
changes: Some(

View file

@ -328,6 +328,7 @@
"quickfix",
),
),
command: None,
edit: Some(
SnippetWorkspaceEdit {
changes: Some(

View file

@ -204,6 +204,7 @@ fn map_rust_child_diagnostic(
}),
is_preferred: Some(true),
data: None,
command: None,
},
}),
})

View file

@ -1160,8 +1160,9 @@ pub(crate) fn handle_code_action_resolve(
))
.into());
}
let edit = to_proto::code_action(&snap, assist.clone(), None)?.edit;
code_action.edit = edit;
let ca = to_proto::code_action(&snap, assist.clone(), None)?;
code_action.edit = ca.edit;
code_action.command = ca.command;
Ok(code_action)
}

View file

@ -311,9 +311,8 @@ pub struct CodeAction {
pub group: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub kind: Option<CodeActionKind>,
// We don't handle commands on the client-side
// #[serde(skip_serializing_if = "Option::is_none")]
// pub command: Option<lsp_types::Command>,
#[serde(skip_serializing_if = "Option::is_none")]
pub command: Option<lsp_types::Command>,
#[serde(skip_serializing_if = "Option::is_none")]
pub edit: Option<SnippetWorkspaceEdit>,
#[serde(skip_serializing_if = "Option::is_none")]

View file

@ -1018,7 +1018,13 @@ pub(crate) fn code_action(
edit: None,
is_preferred: None,
data: None,
command: None,
};
if assist.trigger_signature_help && snap.config.client_commands().trigger_parameter_hints {
res.command = Some(command::trigger_parameter_hints());
}
match (assist.source_change, resolve_data) {
(Some(it), _) => res.edit = Some(snippet_workspace_edit(snap, it)?),
(None, Some((index, code_action_params))) => {