Skip to content

Commit bfa6a5c

Browse files
committed
Address feedback from @DropDemBits
- move `edit.rename()` to the end of the function - use a match statement to set `res.command`
1 parent 8efe8a8 commit bfa6a5c

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

crates/ide-assists/src/handlers/extract_variable.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
135135
}
136136
}
137137
}
138-
edit.rename();
139138
}
140139
Anchor::Replace(stmt) => {
141140
cov_mark::hit!(test_extract_var_expr_stmt);
@@ -150,7 +149,6 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
150149
}
151150
}
152151
}
153-
edit.rename();
154152
}
155153
Anchor::WrapInBlock(to_wrap) => {
156154
let indent_to = to_wrap.indent_level();
@@ -194,12 +192,12 @@ pub(crate) fn extract_variable(acc: &mut Assists, ctx: &AssistContext<'_>) -> Op
194192
}
195193
}
196194
}
197-
edit.rename();
198195

199196
// fixup indentation of block
200197
block.indent(indent_to);
201198
}
202199
}
200+
edit.rename();
203201
},
204202
)
205203
}

crates/rust-analyzer/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ pub struct WorkspaceSymbolConfig {
11281128
/// How many items are returned at most.
11291129
pub search_limit: usize,
11301130
}
1131-
1131+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11321132
pub struct ClientCommandsConfig {
11331133
pub run_single: bool,
11341134
pub debug_single: bool,

crates/rust-analyzer/src/lsp/to_proto.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,15 +1336,14 @@ pub(crate) fn code_action(
13361336
command: None,
13371337
};
13381338

1339-
if assist.command == Some(assists::Command::TriggerSignatureHelp)
1340-
&& snap.config.client_commands().trigger_parameter_hints
1341-
{
1342-
res.command = Some(command::trigger_parameter_hints());
1343-
} else if assist.command == Some(assists::Command::Rename)
1344-
&& snap.config.client_commands().rename
1345-
{
1346-
res.command = Some(command::rename());
1347-
}
1339+
let commands = snap.config.client_commands();
1340+
res.command = match assist.command {
1341+
Some(assists::Command::TriggerSignatureHelp) if commands.trigger_parameter_hints => {
1342+
Some(command::trigger_parameter_hints())
1343+
}
1344+
Some(assists::Command::Rename) if commands.rename => Some(command::rename()),
1345+
_ => None,
1346+
};
13481347

13491348
match (assist.source_change, resolve_data) {
13501349
(Some(it), _) => res.edit = Some(snippet_workspace_edit(snap, it)?),

0 commit comments

Comments
 (0)