From 22280b65ff53fc207999d3a4e41b5ddf395e77cb Mon Sep 17 00:00:00 2001 From: roife Date: Wed, 25 Dec 2024 16:12:56 +0800 Subject: [PATCH] feat: add config `UpdateTest` to hover actions --- crates/rust-analyzer/src/config.rs | 10 +++++++++- crates/rust-analyzer/src/handlers/request.rs | 2 +- docs/user/generated_config.adoc | 6 ++++++ editors/code/package.json | 10 ++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 1b37ab0aab..e240318a13 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -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, @@ -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, } @@ -1236,6 +1240,7 @@ impl HoverActionsConfig { references: false, run: false, debug: false, + update_test: false, goto_type_def: false, }; @@ -1248,7 +1253,7 @@ impl HoverActionsConfig { } 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(), 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(), } } diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs index a152a0fd69..d18bc728b5 100644 --- a/crates/rust-analyzer/src/handlers/request.rs +++ b/crates/rust-analyzer/src/handlers/request.rs @@ -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())); } diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index f5cdcc2b72..c78d577fff 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc @@ -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`):: + -- diff --git a/editors/code/package.json b/editors/code/package.json index 7dc26c4436..2c7b129618 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -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": {