Address feedback from @DropDemBits

- move `edit.rename()` to the end of the function
- use a match statement to set `res.command`
This commit is contained in:
Josh McKinney 2024-07-13 19:33:35 -07:00
parent 8efe8a8528
commit bfa6a5ca84
No known key found for this signature in database
GPG key ID: 722287396A903BC5
3 changed files with 10 additions and 13 deletions

View file

@ -135,7 +135,6 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
} }
} }
} }
edit.rename();
} }
Anchor::Replace(stmt) => { Anchor::Replace(stmt) => {
cov_mark::hit!(test_extract_var_expr_stmt); cov_mark::hit!(test_extract_var_expr_stmt);
@ -150,7 +149,6 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
} }
} }
} }
edit.rename();
} }
Anchor::WrapInBlock(to_wrap) => { Anchor::WrapInBlock(to_wrap) => {
let indent_to = to_wrap.indent_level(); let indent_to = to_wrap.indent_level();
@ -194,12 +192,12 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
} }
} }
} }
edit.rename();
// fixup indentation of block // fixup indentation of block
block.indent(indent_to); block.indent(indent_to);
} }
} }
edit.rename();
}, },
) )
} }

View file

@ -1128,7 +1128,7 @@ pub struct WorkspaceSymbolConfig {
/// How many items are returned at most. /// How many items are returned at most.
pub search_limit: usize, pub search_limit: usize,
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ClientCommandsConfig { pub struct ClientCommandsConfig {
pub run_single: bool, pub run_single: bool,
pub debug_single: bool, pub debug_single: bool,

View file

@ -1336,15 +1336,14 @@ pub(crate) fn code_action(
command: None, command: None,
}; };
if assist.command == Some(assists::Command::TriggerSignatureHelp) let commands = snap.config.client_commands();
&& snap.config.client_commands().trigger_parameter_hints res.command = match assist.command {
{ Some(assists::Command::TriggerSignatureHelp) if commands.trigger_parameter_hints => {
res.command = Some(command::trigger_parameter_hints()); Some(command::trigger_parameter_hints())
} else if assist.command == Some(assists::Command::Rename) }
&& snap.config.client_commands().rename Some(assists::Command::Rename) if commands.rename => Some(command::rename()),
{ _ => None,
res.command = Some(command::rename()); };
}
match (assist.source_change, resolve_data) { match (assist.source_change, resolve_data) {
(Some(it), _) => res.edit = Some(snippet_workspace_edit(snap, it)?), (Some(it), _) => res.edit = Some(snippet_workspace_edit(snap, it)?),