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] Allow to stop cargo on command #6895

Closed
Tracked by #86
jmg-duarte opened this issue Dec 15, 2020 · 3 comments · Fixed by #13427
Closed
Tracked by #86

[VSCode] Allow to stop cargo on command #6895

jmg-duarte opened this issue Dec 15, 2020 · 3 comments · Fixed by #13427
Labels
A-diagnostics diagnostics / error reporting E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now

Comments

@jmg-duarte
Copy link

jmg-duarte commented Dec 15, 2020

I've started developing some macros and recently I've hit a bug in my code which produced an infinite loop.
Once rust-analyzer starts running cargo the only way to stop it is to stop VSCode, this really hurts development, since VSCode now has the lock for the repo.
I should not need to stop the IDE to kill an external program from running, neither should I be expected to kill it with kill.
And even if I do kill it with kill, VSCode just restarts it...

A solution could be adding a button in the following dialog, which sends a SIGTERM signal to cargo?
image

@kjeremy
Copy link
Contributor

kjeremy commented Dec 15, 2020

I think the steps to solve this would be as follows:

  1. Mark the flyweight progress tasks as cancellable and send that to the client. This would allow the client to present a UI suitable for cancellation
    https://github.com/rust-analyzer/rust-analyzer/blob/4d4f11925f793c45560c45c088d4b3139c2c171c/crates/rust-analyzer/src/lsp_utils.rs#L64-L76
  2. Respond to cancel notifications from the client (fix Respond to WorkDoneProgressCancel notification #6782)
  3. Murder the cargo check progress in cold blood.

We would probably need to store a map of progress tokens -> tasks somewhere.

@jmg-duarte
Copy link
Author

@kjeremy thank you for the swift and comprehensive reply!
I'll try to look into it as I'd love to help.

@jonas-schievink jonas-schievink added A-diagnostics diagnostics / error reporting E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now labels Dec 15, 2020
@DJMcNab
Copy link
Contributor

DJMcNab commented Dec 20, 2020

An alternative approach could be to add a concept of 'weak' processes to cargo itself. That is a 'weak' process, such as cargo check from within rust-analyzer would stop when cargo build is executed (using some method - creating a file?). That however is significantly more involved, and would be tangential to the suggested solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting E-has-instructions Issue has some instructions and pointers to code to get started S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants