From 2bfa83beb36e7aa9d55baffa1ab2d076157bba97 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 --- .../rust-analyzer/crates/rust-analyzer/src/config.rs | 10 +++++++++- .../crates/rust-analyzer/src/handlers/request.rs | 2 +- .../rust-analyzer/docs/user/generated_config.adoc | 6 ++++++ src/tools/rust-analyzer/editors/code/package.json | 10 ++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs index 1b37ab0aab2da..e240318a13a21 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs +++ b/src/tools/rust-analyzer/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/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs index a152a0fd69836..d18bc728b578f 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs +++ b/src/tools/rust-analyzer/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/src/tools/rust-analyzer/docs/user/generated_config.adoc b/src/tools/rust-analyzer/docs/user/generated_config.adoc index f5cdcc2b726ed..c78d577fff418 100644 --- a/src/tools/rust-analyzer/docs/user/generated_config.adoc +++ b/src/tools/rust-analyzer/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/src/tools/rust-analyzer/editors/code/package.json b/src/tools/rust-analyzer/editors/code/package.json index 7dc26c443665d..2c7b129618b88 100644 --- a/src/tools/rust-analyzer/editors/code/package.json +++ b/src/tools/rust-analyzer/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": {