diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index be8688bc395..76ed6f29ad9 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), diff --git a/editors/code/src/debug.ts b/editors/code/src/debug.ts index 966019883dd..1f93a2b7ec4 100644 --- a/editors/code/src/debug.ts +++ b/editors/code/src/debug.ts @@ -88,8 +88,9 @@ export async function getDebugConfiguration(ctx: Ctx, config: ra.Runnable): Prom } if (debugConfig.name === "run binary") { - // A workaround for multiple binaries. It would be better to get proper names on the LSP side. - debugConfig.name = `run binary [${path.basename(executable)}]`; + // The LSP side: crates\rust-analyzer\src\main_loop\handlers.rs, + // fn to_lsp_runnable(...) with RunnableKind::Bin + debugConfig.name = `run binary '${path.basename(executable)}'`; } if (debugConfig.cwd) {