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",
|
RunnableKind::Bin => "Run",
|
||||||
}
|
}
|
||||||
.to_string();
|
.to_string();
|
||||||
let r = to_lsp_runnable(&world, file_id, runnable)?;
|
let mut r = to_lsp_runnable(&world, file_id, runnable)?;
|
||||||
let range = r.range;
|
|
||||||
let arguments = vec![to_value(r).unwrap()];
|
|
||||||
let lens = CodeLens {
|
let lens = CodeLens {
|
||||||
range: range.clone(),
|
range: r.range,
|
||||||
command: Some(Command {
|
command: Some(Command {
|
||||||
title,
|
title,
|
||||||
command: "rust-analyzer.runSingle".into(),
|
command: "rust-analyzer.runSingle".into(),
|
||||||
arguments: Some(arguments.clone()),
|
arguments: Some(vec![to_value(&r).unwrap()]),
|
||||||
}),
|
}),
|
||||||
data: None,
|
data: None,
|
||||||
};
|
};
|
||||||
|
if r.args[0] == "run" {
|
||||||
|
r.args[0] = "build".into();
|
||||||
|
} else {
|
||||||
|
r.args.push("--no-run".into());
|
||||||
|
}
|
||||||
let debug_lens = CodeLens {
|
let debug_lens = CodeLens {
|
||||||
range,
|
range: r.range,
|
||||||
command: Some(Command {
|
command: Some(Command {
|
||||||
title: "Debug".into(),
|
title: "Debug".into(),
|
||||||
command: "rust-analyzer.debugSingle".into(),
|
command: "rust-analyzer.debugSingle".into(),
|
||||||
arguments: Some(arguments.clone()),
|
arguments: Some(vec![to_value(r).unwrap()]),
|
||||||
}),
|
}),
|
||||||
data: None,
|
data: None,
|
||||||
};
|
};
|
||||||
|
@ -143,10 +143,7 @@ fn main() {}
|
|||||||
|
|
||||||
server.wait_until_workspace_is_loaded();
|
server.wait_until_workspace_is_loaded();
|
||||||
server.request::<Runnables>(
|
server.request::<Runnables>(
|
||||||
RunnablesParams {
|
RunnablesParams { text_document: server.doc_id("foo/tests/spam.rs"), position: None },
|
||||||
text_document: server.doc_id("foo/tests/spam.rs"),
|
|
||||||
position: None,
|
|
||||||
},
|
|
||||||
json!([
|
json!([
|
||||||
{
|
{
|
||||||
"args": [ "test", "--package", "foo", "--test", "spam" ],
|
"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;
|
const editor = ctx.activeRustEditor;
|
||||||
if (!editor) return;
|
if (!editor) return;
|
||||||
|
|
||||||
if (config.args[0] === 'run') {
|
|
||||||
config.args[0] = 'build';
|
|
||||||
} else {
|
|
||||||
config.args.push('--no-run');
|
|
||||||
}
|
|
||||||
|
|
||||||
const debugConfig = {
|
const debugConfig = {
|
||||||
type: "lldb",
|
type: "lldb",
|
||||||
request: "launch",
|
request: "launch",
|
||||||
@ -83,6 +77,7 @@ export function debugSingle(ctx: Ctx): Cmd {
|
|||||||
args: config.extraArgs,
|
args: config.extraArgs,
|
||||||
cwd: config.cwd
|
cwd: config.cwd
|
||||||
};
|
};
|
||||||
|
|
||||||
return vscode.debug.startDebugging(undefined, debugConfig);
|
return vscode.debug.startDebugging(undefined, debugConfig);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user