mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Multiple binaries support for launch.json.
Generate unique names on the LSP side.
This commit is contained in:
parent
5f6cdae18f
commit
20fdd14c62
2 changed files with 7 additions and 3 deletions
|
@ -1011,6 +1011,7 @@ fn to_lsp_runnable(
|
|||
runnable: Runnable,
|
||||
) -> Result<lsp_ext::Runnable> {
|
||||
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),
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue