KEMBAR78
feat: Extend vscode 'run' command with optional mode argument for run… by markpots5 · Pull Request #20077 · rust-lang/rust-analyzer · GitHub
Skip to content

Conversation

@markpots5
Copy link
Contributor

…ning test(s) or bin at keyboard cursor

Fixes #14805

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 23, 2025
@markpots5
Copy link
Contributor Author

markpots5 commented Jun 23, 2025

To test executing the 'run' command with 'cursor' as supplied argument one can for example add the following to keybindings.json:
{ "key": "ctrl+p", "command": "rust-analyzer.run", "args": "cursor" }

Comment on lines 468 to 476
if (name === "run") {
// Special case: support optional argument for `run`
callback = (mode?: "cursor") => {
return commands.run(this, mode)();
};
} else {
// we asserted that `client` is defined
callback = factory.enabled(this);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary, Cmd (the type of callback) is already correctly typed in allowing more parameters. Instead we need to change the enabled field here

run: { enabled: commands.run },
to take the special callback instead

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah In fact that doesn't need changes either. Just having edited the signature of command.run should suffice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it. I've tried to only revert the special casing in command factory (ctx.ts). However it seems adding the special callback as you suggest in your first comment is necessary to make it work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah indeed, enabled is not a Cmd but a function that returns a Cmd 👍

@Veykril
Copy link
Member

Veykril commented Jun 25, 2025

Thanks!

@Veykril Veykril added this pull request to the merge queue Jun 25, 2025
Merged via the queue into rust-lang:master with commit 756f1bf Jun 25, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard shortcut for running unit tests

3 participants