fixup! feat: add debug code lens
avoid repetition of `--no-run`
This commit is contained in:
parent
a034257e5e
commit
e9d025b618
@ -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,
|
||||
};
|
||||
|
@ -143,10 +143,7 @@ fn main() {}
|
||||
|
||||
server.wait_until_workspace_is_loaded();
|
||||
server.request::<Runnables>(
|
||||
RunnablesParams {
|
||||
text_document: server.doc_id("foo/tests/spam.rs"),
|
||||
position: None,
|
||||
},
|
||||
RunnablesParams { text_document: server.doc_id("foo/tests/spam.rs"), position: None },
|
||||
json!([
|
||||
{
|
||||
"args": [ "test", "--package", "foo", "--test", "spam" ],
|
||||
@ -184,7 +181,7 @@ fn main() {}
|
||||
}
|
||||
}
|
||||
}
|
||||
])
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -67,12 +67,6 @@ export function debugSingle(ctx: Ctx): Cmd {
|
||||
const editor = ctx.activeRustEditor;
|
||||
if (!editor) return;
|
||||
|
||||
if (config.args[0] === 'run') {
|
||||
config.args[0] = 'build';
|
||||
} else {
|
||||
config.args.push('--no-run');
|
||||
}
|
||||
|
||||
const debugConfig = {
|
||||
type: "lldb",
|
||||
request: "launch",
|
||||
@ -83,6 +77,7 @@ export function debugSingle(ctx: Ctx): Cmd {
|
||||
args: config.extraArgs,
|
||||
cwd: config.cwd
|
||||
};
|
||||
|
||||
return vscode.debug.startDebugging(undefined, debugConfig);
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user