Skip to content

Commit 2bfa83b

Browse files
committed
feat: add config UpdateTest to hover actions
1 parent 147d1dd commit 2bfa83b

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ config_data! {
119119
/// Whether to show `Run` action. Only applies when
120120
/// `#rust-analyzer.hover.actions.enable#` is set.
121121
hover_actions_run_enable: bool = true,
122+
/// Whether to show `Update Test` action. Only applies when
123+
/// `#rust-analyzer.hover.actions.enable#` and `#rust-analyzer.hover.actions.run.enable#` are set.
124+
hover_actions_updateTest_enable: bool = true,
122125

123126
/// Whether to show documentation on hover.
124127
hover_documentation_enable: bool = true,
@@ -1227,6 +1230,7 @@ pub struct HoverActionsConfig {
12271230
pub references: bool,
12281231
pub run: bool,
12291232
pub debug: bool,
1233+
pub update_test: bool,
12301234
pub goto_type_def: bool,
12311235
}
12321236

@@ -1236,6 +1240,7 @@ impl HoverActionsConfig {
12361240
references: false,
12371241
run: false,
12381242
debug: false,
1243+
update_test: false,
12391244
goto_type_def: false,
12401245
};
12411246

@@ -1248,7 +1253,7 @@ impl HoverActionsConfig {
12481253
}
12491254

12501255
pub fn runnable(&self) -> bool {
1251-
self.run || self.debug
1256+
self.run || self.debug || self.update_test
12521257
}
12531258
}
12541259

@@ -1522,6 +1527,9 @@ impl Config {
15221527
references: enable && self.hover_actions_references_enable().to_owned(),
15231528
run: enable && self.hover_actions_run_enable().to_owned(),
15241529
debug: enable && self.hover_actions_debug_enable().to_owned(),
1530+
update_test: enable
1531+
&& self.hover_actions_run_enable().to_owned()
1532+
&& self.hover_actions_updateTest_enable().to_owned(),
15251533
goto_type_def: enable && self.hover_actions_gotoTypeDef_enable().to_owned(),
15261534
}
15271535
}

src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,7 @@ fn runnable_action_links(
21582158
group.commands.push(to_command_link(dbg_command, r.label.clone()));
21592159
}
21602160

2161-
if client_commands_config.update_single {
2161+
if hover_actions_config.update_test && client_commands_config.update_single {
21622162
if let Some(update_command) = to_proto::command::update_single(&r, &update_test.label()) {
21632163
group.commands.push(to_command_link(update_command, r.label.clone()));
21642164
}

src/tools/rust-analyzer/docs/user/generated_config.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@ Whether to show `References` action. Only applies when
497497
Whether to show `Run` action. Only applies when
498498
`#rust-analyzer.hover.actions.enable#` is set.
499499
--
500+
[[rust-analyzer.hover.actions.updateTest.enable]]rust-analyzer.hover.actions.updateTest.enable (default: `true`)::
501+
+
502+
--
503+
Whether to show `Update Test` action. Only applies when
504+
`#rust-analyzer.hover.actions.enable#` and `#rust-analyzer.hover.actions.run.enable#` are set.
505+
--
500506
[[rust-analyzer.hover.documentation.enable]]rust-analyzer.hover.documentation.enable (default: `true`)::
501507
+
502508
--

src/tools/rust-analyzer/editors/code/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,16 @@
15201520
}
15211521
}
15221522
},
1523+
{
1524+
"title": "hover",
1525+
"properties": {
1526+
"rust-analyzer.hover.actions.updateTest.enable": {
1527+
"markdownDescription": "Whether to show `Update Test` action. Only applies when\n`#rust-analyzer.hover.actions.enable#` and `#rust-analyzer.hover.actions.run.enable#` are set.",
1528+
"default": true,
1529+
"type": "boolean"
1530+
}
1531+
}
1532+
},
15231533
{
15241534
"title": "hover",
15251535
"properties": {

0 commit comments

Comments
 (0)