Skip to content

Commit 20fdd14

Browse files
committed
Multiple binaries support for launch.json.
Generate unique names on the LSP side.
1 parent 5f6cdae commit 20fdd14

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

crates/rust-analyzer/src/main_loop/handlers.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,14 +1011,17 @@ fn to_lsp_runnable(
10111011
runnable: Runnable,
10121012
) -> Result<lsp_ext::Runnable> {
10131013
let spec = CargoTargetSpec::for_file(world, file_id)?;
1014+
let target = spec.as_ref().map(|s| s.target.clone());
10141015
let (args, extra_args) = CargoTargetSpec::runnable_args(spec, &runnable.kind)?;
10151016
let line_index = world.analysis().file_line_index(file_id)?;
10161017
let label = match &runnable.kind {
10171018
RunnableKind::Test { test_id, .. } => format!("test {}", test_id),
10181019
RunnableKind::TestMod { path } => format!("test-mod {}", path),
10191020
RunnableKind::Bench { test_id } => format!("bench {}", test_id),
10201021
RunnableKind::DocTest { test_id, .. } => format!("doctest {}", test_id),
1021-
RunnableKind::Bin => "run binary".to_string(),
1022+
RunnableKind::Bin => {
1023+
target.map_or_else(|| "run binary".to_string(), |t| format!("run binary '{}'", t))
1024+
}
10221025
};
10231026
Ok(lsp_ext::Runnable {
10241027
range: to_proto::range(&line_index, runnable.range),

editors/code/src/debug.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,9 @@ export async function getDebugConfiguration(ctx: Ctx, config: ra.Runnable): Prom
8888
}
8989

9090
if (debugConfig.name === "run binary") {
91-
// A workaround for multiple binaries. It would be better to get proper names on the LSP side.
92-
debugConfig.name = `run binary [${path.basename(executable)}]`;
91+
// The LSP side: crates\rust-analyzer\src\main_loop\handlers.rs,
92+
// fn to_lsp_runnable(...) with RunnableKind::Bin
93+
debugConfig.name = `run binary '${path.basename(executable)}'`;
9394
}
9495

9596
if (debugConfig.cwd) {

0 commit comments

Comments
 (0)