feat(lsp): add debugOverrideCommand option#22236
Conversation
This comment has been minimized.
This comment has been minimized.
a7a3150 to
0e6e8b5
Compare
This comment has been minimized.
This comment has been minimized.
| @@ -453,6 +453,15 @@ pub struct Runnable { | |||
| pub location: Option<lsp_types::LocationLink>, | |||
| pub kind: RunnableKind, | |||
There was a problem hiding this comment.
Makes sense to also use RunnableCommand here? You can use serde(flatten).
| location: Some(location), | ||
| kind: lsp_ext::RunnableKind::Shell, | ||
| args: lsp_ext::RunnableArgs::Shell(runnable_args), | ||
| debug: None, |
There was a problem hiding this comment.
Why don't we pass debug here too? It's even more useful for rust-project.json.
| executable_args, | ||
| environment: Default::default(), | ||
| }), | ||
| debug: None, |
There was a problem hiding this comment.
And here too.
| /// - `${include_ignored}`: always empty for benchmarks. | ||
| /// - `${executable_args}`: all of the above binary args bundled together | ||
| /// (includes `rust-analyzer.runnables.extraTestBinaryArgs`). | ||
| runnables_bench_debugOverrideCommand: Option<Vec<String>> = None, |
There was a problem hiding this comment.
overrideDebugCommand makes more sense, the current name sounds like we're debugging the override.
| env: includeShellExtraEnv | ||
| ? prepareEnv( | ||
| true, | ||
| runnableArgs.environment, | ||
| config.runnablesExtraEnv(runnable.label), | ||
| ) | ||
| : prepareBaseEnv(true), |
There was a problem hiding this comment.
Why is this?
There was a problem hiding this comment.
This only affects shell commands launched by the VS Code Debug action. Regular shell Run actions from overrideCommand or rust-project.json keep their existing environment behavior. Debug shell tasks can use rust-analyzer.runnables.extraEnv, for example to pass CODELLDB_LAUNCH_CONFIG for CodeLLDB + nextest.
5aea419 to
6547d35
Compare
Co-authored-by: Copilot <copilot@github.com>
6547d35 to
ec796ea
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Closes #22128
Adds
debugOverrideCommandfor test and bench runnables so debug can use a different command from Run. This is needed for runners like nextest, where running a test and debugging a test require different command shapes.The setting is opt-in. Existing
overrideCommand, Cargo debug config generation, and matchinglaunch.jsonentries keep their current behavior.For reference, here's my setup with this PR active.
{ "rust-analyzer.server.path": "$HOME/Workspaces/rust-analyzer/target/debug/rust-analyzer", "rust-analyzer.runnables.test.overrideCommand": [ "nix", "shell", "nixpkgs#cargo-nextest", "-c", "cargo", "nextest", "run", "--config", "profile.dev.debug=2", "--package", "${package}", "${target_arg}", "${target}", "--", "${test_name}", "${exact}", "${include_ignored}" ], "rust-analyzer.runnables.test.debugOverrideCommand": [ "nix", "shell", "nixpkgs#cargo-nextest", "-c", "cargo", "nextest", "run", "--config", "profile.dev.debug=2", "--package", "${package}", "${target_arg}", "${target}", "--debugger", "$HOME/.vscode/extensions/vadimcn.vscode-lldb-1.12.1/bin/codelldb-launch --connect 127.0.0.1:12345 --", "--", "${test_name}", "${exact}", "${include_ignored}" ], "rust-analyzer.runnables.extraEnv": { "CODELLDB_LAUNCH_CONFIG": "{ token: 'secret' }" }, "lldb.rpcServer": { "host": "127.0.0.1", "port": 12345, "token": "secret" } }