mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
Change enableCargoWatchOnStartup to have three states
This fixes #1005. Defaults to `ask` which prompts users each time whether to start `cargo watch` or not. `enabled` always starts `cargo watch` and `disabled` does not.
This commit is contained in:
parent
aa0cc0c609
commit
5c3e9c716e
3 changed files with 31 additions and 16 deletions
|
@ -153,22 +153,25 @@ export const autoCargoWatchTask: vscode.Task = {
|
|||
* that, when accepted, allow us to `cargo install cargo-watch` and then run it.
|
||||
*/
|
||||
export async function interactivelyStartCargoWatch() {
|
||||
if (!Server.config.enableCargoWatchOnStartup) {
|
||||
if (Server.config.enableCargoWatchOnStartup === 'disabled') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Server.config.enableCargoWatchOnStartup === 'ask') {
|
||||
const watch = await vscode.window.showInformationMessage(
|
||||
'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)',
|
||||
'yes',
|
||||
'no'
|
||||
);
|
||||
if (watch === 'no') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const execPromise = util.promisify(child_process.exec);
|
||||
|
||||
const watch = await vscode.window.showInformationMessage(
|
||||
'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)',
|
||||
'yes',
|
||||
'no'
|
||||
);
|
||||
if (watch === 'no') {
|
||||
return;
|
||||
}
|
||||
|
||||
const { stderr } = await execPromise('cargo watch --version').catch(e => e);
|
||||
|
||||
if (stderr.includes('no such subcommand: `watch`')) {
|
||||
const msg =
|
||||
'The `cargo-watch` subcommand is not installed. Install? (takes ~1-2 minutes)';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue