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