diff --git a/crates/rust-analyzer/src/main_loop/handlers.rs b/crates/rust-analyzer/src/main_loop/handlers.rs index 07761f00ac..f9715e675c 100644 --- a/crates/rust-analyzer/src/main_loop/handlers.rs +++ b/crates/rust-analyzer/src/main_loop/handlers.rs @@ -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, }; diff --git a/crates/rust-analyzer/tests/heavy_tests/main.rs b/crates/rust-analyzer/tests/heavy_tests/main.rs index 55af6c5e0a..145429571c 100644 --- a/crates/rust-analyzer/tests/heavy_tests/main.rs +++ b/crates/rust-analyzer/tests/heavy_tests/main.rs @@ -143,10 +143,7 @@ fn main() {} server.wait_until_workspace_is_loaded(); server.request::( - 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() {} } } } - ]) + ]), ); } diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 51cfb37d54..357155163d 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts @@ -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); }; }