Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vscode] Support workbench.action.debug.start and workbench.action.debug.run #4475

Closed
teohhanhui opened this issue May 16, 2020 · 8 comments
Closed

Comments

@teohhanhui
Copy link

Currently, there is Run | Debug above fn main() {, which works well, but is kind of annoying as it is always visible.

It would be better if the built-in commands could be used (without configuring launch.json), same as what was described in rust-lang/vscode-rust#557 (comment)

@vsrs
Copy link
Contributor

vsrs commented May 16, 2020

"editor.codeLens" in settings.json will disable Run | Debug (and X implementations lens for structs as well)

It's wrong to use workbench.action.debug.start or workbench.action.debug.run since it is private vscode API. Public one is startDebugging and it is used in the Debug Lens internally.

BTW, #4448 made launch.json configuration pretty trivial. Might be it will work for you?

@teohhanhui
Copy link
Author

"editor.codeLens" in settings.json will disable Run | Debug

That's the nuclear option. I do want code lens, just not this code lens (because running / debugging the program is something that the debug / run commands are for, I don't see why they should be triggered through a code lens). But it's a minor thing that I can live with.

It's wrong to use workbench.action.debug.start or workbench.action.debug.run since it is private vscode API. Public one is startDebugging and it is used in the Debug Lens internally.

That's not what I meant at all. Let me clarify. There are different providers (I don't know what the correct term is) when you try to use the debug / run commands, including Node.js (built-in one). I understand that "debugger extensions" can add providers to that list: https://code.visualstudio.com/api/extension-guides/debugger-extension - for example, the C/C++ extension adds a provider there - it's the same idea mentioned in rust-lang/vscode-rust#557 (comment)

@vsrs
Copy link
Contributor

vsrs commented May 16, 2020

That's the nuclear option.

Agreed. We can have a separate configuration option to hide Run | Debug. Easy to add.

There are different providers...

I see. You are talking about DebugConfigurationProvider (DCP) . There are two difficulties with them:

  1. At the moment there is no way to export a debug configuration from a DCP to the launch.json.

  2. There might be numerous debug targets (hundreds of tests for example) and it takes significant time to find them all and make available via the DCP. The current solution, on the other side, looks for runnables only in the current file. It is much faster.

The former scheduled to be fixed in the next vscode milestone. But the latter stops me from implementing DCP.

@vsrs
Copy link
Contributor

vsrs commented May 16, 2020

Hmm, though it should be possible to dynamically update DCP and show only runnables from the current file. It's a DCP new feature from the April vscode (version 1.45). I'll take a stab at this.

@teohhanhui
Copy link
Author

I'm very new to Rust, but is it not possible to just support cargo run? For an end user like me, it seems correct that that's what the debug / run commands should do.

@vsrs
Copy link
Contributor

vsrs commented May 17, 2020

just support cargo run

This is exactly what rust-analyzer.run command does (obviously it uses cargo test for tests). rust-analyzer.debug is a bit trickier, but in the end it also uses cargo commands.

@vsrs
Copy link
Contributor

vsrs commented May 18, 2020

We can have a separate configuration option to hide Run | Debug. Easy to add.

Done in #4499

@matklad
Copy link
Member

matklad commented Jul 12, 2020

I believe we need API from LSP/VS Code to make this work really nice: microsoft/language-server-protocol#944

@matklad matklad closed this as completed Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants