fixup! feat: add debug code lens

avoid repetition of `--no-run`
This commit is contained in:
Hannes De Valkeneer
2020-03-12 21:28:26 +01:00
parent a034257e5e
commit e9d025b618
3 changed files with 13 additions and 18 deletions

View File

@@ -795,24 +795,27 @@ pub fn handle_code_lens(
RunnableKind::Bin => "Run",
}
.to_string();
let r = to_lsp_runnable(&world, file_id, runnable)?;
let range = r.range;
let arguments = vec![to_value(r).unwrap()];
let mut r = to_lsp_runnable(&world, file_id, runnable)?;
let lens = CodeLens {
range: range.clone(),
range: r.range,
command: Some(Command {
title,
command: "rust-analyzer.runSingle".into(),
arguments: Some(arguments.clone()),
arguments: Some(vec![to_value(&r).unwrap()]),
}),
data: None,
};
if r.args[0] == "run" {
r.args[0] = "build".into();
} else {
r.args.push("--no-run".into());
}
let debug_lens = CodeLens {
range,
range: r.range,
command: Some(Command {
title: "Debug".into(),
command: "rust-analyzer.debugSingle".into(),
arguments: Some(arguments.clone()),
arguments: Some(vec![to_value(r).unwrap()]),
}),
data: None,
};