feat: add config UpdateTest to hover actions

This commit is contained in:
roife 2024-12-25 16:12:56 +08:00
parent 57cd0d5dbe
commit 22280b65ff
4 changed files with 26 additions and 2 deletions

View file

@ -119,6 +119,9 @@ config_data! {
/// Whether to show `Run` action. Only applies when /// Whether to show `Run` action. Only applies when
/// `#rust-analyzer.hover.actions.enable#` is set. /// `#rust-analyzer.hover.actions.enable#` is set.
hover_actions_run_enable: bool = true, hover_actions_run_enable: bool = true,
/// Whether to show `Update Test` action. Only applies when
/// `#rust-analyzer.hover.actions.enable#` and `#rust-analyzer.hover.actions.run.enable#` are set.
hover_actions_updateTest_enable: bool = true,
/// Whether to show documentation on hover. /// Whether to show documentation on hover.
hover_documentation_enable: bool = true, hover_documentation_enable: bool = true,
@ -1227,6 +1230,7 @@ pub struct HoverActionsConfig {
pub references: bool, pub references: bool,
pub run: bool, pub run: bool,
pub debug: bool, pub debug: bool,
pub update_test: bool,
pub goto_type_def: bool, pub goto_type_def: bool,
} }
@ -1236,6 +1240,7 @@ impl HoverActionsConfig {
references: false, references: false,
run: false, run: false,
debug: false, debug: false,
update_test: false,
goto_type_def: false, goto_type_def: false,
}; };
@ -1248,7 +1253,7 @@ impl HoverActionsConfig {
} }
pub fn runnable(&self) -> bool { pub fn runnable(&self) -> bool {
self.run || self.debug self.run || self.debug || self.update_test
} }
} }
@ -1522,6 +1527,9 @@ impl Config {
references: enable && self.hover_actions_references_enable().to_owned(), references: enable && self.hover_actions_references_enable().to_owned(),
run: enable && self.hover_actions_run_enable().to_owned(), run: enable && self.hover_actions_run_enable().to_owned(),
debug: enable && self.hover_actions_debug_enable().to_owned(), debug: enable && self.hover_actions_debug_enable().to_owned(),
update_test: enable
&& self.hover_actions_run_enable().to_owned()
&& self.hover_actions_updateTest_enable().to_owned(),
goto_type_def: enable && self.hover_actions_gotoTypeDef_enable().to_owned(), goto_type_def: enable && self.hover_actions_gotoTypeDef_enable().to_owned(),
} }
} }

View file

@ -2158,7 +2158,7 @@ fn runnable_action_links(
group.commands.push(to_command_link(dbg_command, r.label.clone())); group.commands.push(to_command_link(dbg_command, r.label.clone()));
} }
if client_commands_config.update_single { if hover_actions_config.update_test && client_commands_config.update_single {
if let Some(update_command) = to_proto::command::update_single(&r, &update_test.label()) { if let Some(update_command) = to_proto::command::update_single(&r, &update_test.label()) {
group.commands.push(to_command_link(update_command, r.label.clone())); group.commands.push(to_command_link(update_command, r.label.clone()));
} }

View file

@ -497,6 +497,12 @@ Whether to show `References` action. Only applies when
Whether to show `Run` action. Only applies when Whether to show `Run` action. Only applies when
`#rust-analyzer.hover.actions.enable#` is set. `#rust-analyzer.hover.actions.enable#` is set.
-- --
[[rust-analyzer.hover.actions.updateTest.enable]]rust-analyzer.hover.actions.updateTest.enable (default: `true`)::
+
--
Whether to show `Update Test` action. Only applies when
`#rust-analyzer.hover.actions.enable#` and `#rust-analyzer.hover.actions.run.enable#` are set.
--
[[rust-analyzer.hover.documentation.enable]]rust-analyzer.hover.documentation.enable (default: `true`):: [[rust-analyzer.hover.documentation.enable]]rust-analyzer.hover.documentation.enable (default: `true`)::
+ +
-- --

View file

@ -1520,6 +1520,16 @@
} }
} }
}, },
{
"title": "hover",
"properties": {
"rust-analyzer.hover.actions.updateTest.enable": {
"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.",
"default": true,
"type": "boolean"
}
}
},
{ {
"title": "hover", "title": "hover",
"properties": { "properties": {