From 20fdd14c62aa9c5327f1e6afc04f01a5af6763fb Mon Sep 17 00:00:00 2001 From: vsrs Date: Thu, 14 May 2020 16:02:01 +0300 Subject: Multiple binaries support for launch.json. Generate unique names on the LSP side. --- crates/rust-analyzer/src/main_loop/handlers.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index be8688bc3..76ed6f29a 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs @@ -1011,6 +1011,7 @@ fn to_lsp_runnable( runnable: Runnable, ) -> Result { let spec = CargoTargetSpec::for_file(world, file_id)?; + let target = spec.as_ref().map(|s| s.target.clone()); let (args, extra_args) = CargoTargetSpec::runnable_args(spec, &runnable.kind)?; let line_index = world.analysis().file_line_index(file_id)?; let label = match &runnable.kind { @@ -1018,7 +1019,9 @@ fn to_lsp_runnable( RunnableKind::TestMod { path } => format!("test-mod {}", path), RunnableKind::Bench { test_id } => format!("bench {}", test_id), RunnableKind::DocTest { test_id, .. } => format!("doctest {}", test_id), - RunnableKind::Bin => "run binary".to_string(), + RunnableKind::Bin => { + target.map_or_else(|| "run binary".to_string(), |t| format!("run binary '{}'", t)) + } }; Ok(lsp_ext::Runnable { range: to_proto::range(&line_index, runnable.range), -- cgit v1.2.3 From 51d5a08255482d6cf7dfcb9e3c6bb1a0aec6379d Mon Sep 17 00:00:00 2001 From: vsrs <62505555+vsrs@users.noreply.github.com> Date: Thu, 14 May 2020 16:28:18 +0300 Subject: Better label for a runnable. Co-authored-by: Aleksey Kladov --- crates/rust-analyzer/src/main_loop/handlers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index 76ed6f29a..a5d0cbe78 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs @@ -1020,7 +1020,7 @@ fn to_lsp_runnable( RunnableKind::Bench { test_id } => format!("bench {}", test_id), RunnableKind::DocTest { test_id, .. } => format!("doctest {}", test_id), RunnableKind::Bin => { - target.map_or_else(|| "run binary".to_string(), |t| format!("run binary '{}'", t)) + target.map_or_else(|| "run binary".to_string(), |t| format!("run {}", t)) } }; Ok(lsp_ext::Runnable { -- cgit v1.2.3