From 59e3d6684b8b37edad9a369960f2d9199e690335 Mon Sep 17 00:00:00 2001 From: roife Date: Sat, 21 Dec 2024 07:03:45 +0800 Subject: [PATCH] fix: only show debug lens with a valid root --- crates/rust-analyzer/src/lsp/to_proto.rs | 34 +++++++++++++----------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/crates/rust-analyzer/src/lsp/to_proto.rs b/crates/rust-analyzer/src/lsp/to_proto.rs index 38bb30c978..05e93b4e6a 100644 --- a/crates/rust-analyzer/src/lsp/to_proto.rs +++ b/crates/rust-analyzer/src/lsp/to_proto.rs @@ -1584,22 +1584,26 @@ pub(crate) fn code_lens( }; let lens_config = snap.config.lens(); - if lens_config.run && client_commands_config.run_single && has_root { - let command = command::run_single(&r, &title); - acc.push(lsp_types::CodeLens { - range: annotation_range, - command: Some(command), - data: None, - }) - } - if lens_config.debug && can_debug && client_commands_config.debug_single { - let command = command::debug_single(&r); - acc.push(lsp_types::CodeLens { - range: annotation_range, - command: Some(command), - data: None, - }) + + if has_root { + if lens_config.run && client_commands_config.run_single { + let command = command::run_single(&r, &title); + acc.push(lsp_types::CodeLens { + range: annotation_range, + command: Some(command), + data: None, + }) + } + if lens_config.debug && can_debug && client_commands_config.debug_single { + let command = command::debug_single(&r); + acc.push(lsp_types::CodeLens { + range: annotation_range, + command: Some(command), + data: None, + }) + } } + if lens_config.interpret { let command = command::interpret_single(&r); acc.push(lsp_types::CodeLens {