Filter out CodeActions if a server only support commands.
This commit is contained in:
@@ -70,6 +70,7 @@ pub struct ClientCapsConfig {
|
||||
pub location_link: bool,
|
||||
pub line_folding_only: bool,
|
||||
pub hierarchical_symbols: bool,
|
||||
pub code_action_literals: bool,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -221,6 +222,11 @@ impl Config {
|
||||
{
|
||||
self.client_caps.hierarchical_symbols = value
|
||||
}
|
||||
if let Some(value) =
|
||||
caps.code_action.as_ref().and_then(|it| Some(it.code_action_literal_support.is_some()))
|
||||
{
|
||||
self.client_caps.code_action_literals = value;
|
||||
}
|
||||
self.completion.allow_snippets(false);
|
||||
if let Some(completion) = &caps.completion {
|
||||
if let Some(completion_item) = &completion.completion_item {
|
||||
|
||||
@@ -812,6 +812,22 @@ pub fn handle_code_action(
|
||||
}
|
||||
}
|
||||
|
||||
// If the client only supports commands then filter the list
|
||||
// and remove and actions that depend on edits.
|
||||
if !world.config.client_caps.code_action_literals {
|
||||
res = res
|
||||
.into_iter()
|
||||
.filter_map(|it| match it {
|
||||
cmd @ lsp_types::CodeActionOrCommand::Command(_) => Some(cmd),
|
||||
lsp_types::CodeActionOrCommand::CodeAction(action) => match action.command {
|
||||
Some(cmd) if action.edit.is_none() => {
|
||||
Some(lsp_types::CodeActionOrCommand::Command(cmd))
|
||||
}
|
||||
_ => None,
|
||||
},
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
Ok(Some(res))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user