Skip to content

Commit

Permalink
feat: add config UpdateTest to hover actions
Browse files Browse the repository at this point in the history
  • Loading branch information
roife committed Dec 26, 2024
1 parent 147d1dd commit 2bfa83b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ config_data! {
/// Whether to show `Run` action. Only applies when
/// `#rust-analyzer.hover.actions.enable#` is set.
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.
hover_documentation_enable: bool = true,
Expand Down Expand Up @@ -1227,6 +1230,7 @@ pub struct HoverActionsConfig {
pub references: bool,
pub run: bool,
pub debug: bool,
pub update_test: bool,
pub goto_type_def: bool,
}

Expand All @@ -1236,6 +1240,7 @@ impl HoverActionsConfig {
references: false,
run: false,
debug: false,
update_test: false,
goto_type_def: false,
};

Expand All @@ -1248,7 +1253,7 @@ impl HoverActionsConfig {
}

pub fn runnable(&self) -> bool {
self.run || self.debug
self.run || self.debug || self.update_test
}
}

Expand Down Expand Up @@ -1522,6 +1527,9 @@ impl Config {
references: enable && self.hover_actions_references_enable().to_owned(),
run: enable && self.hover_actions_run_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(),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,7 @@ fn runnable_action_links(
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()) {
group.commands.push(to_command_link(update_command, r.label.clone()));
}
Expand Down
6 changes: 6 additions & 0 deletions src/tools/rust-analyzer/docs/user/generated_config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,12 @@ Whether to show `References` action. Only applies when
Whether to show `Run` action. Only applies when
`#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`)::
+
--
Expand Down
10 changes: 10 additions & 0 deletions src/tools/rust-analyzer/editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"properties": {
Expand Down

0 comments on commit 2bfa83b

Please sign in to comment.