diff options
author | Ville Penttinen <[email protected]> | 2019-03-21 11:56:25 +0000 |
---|---|---|
committer | Ville Penttinen <[email protected]> | 2019-03-21 11:56:25 +0000 |
commit | 5c3e9c716e11a0b795d484403289fe9940b7efda (patch) | |
tree | acc588e7538f0b682232d7d47a1d7b68ab95b993 /editors/code/src | |
parent | aa0cc0c6096ca8ba80ef225c813fe30310ba6c33 (diff) |
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.
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/commands/runnables.ts | 23 | ||||
-rw-r--r-- | editors/code/src/config.ts | 8 |
2 files changed, 18 insertions, 13 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index ea2883ad4..420635f41 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts | |||
@@ -153,22 +153,25 @@ export const autoCargoWatchTask: vscode.Task = { | |||
153 | * that, when accepted, allow us to `cargo install cargo-watch` and then run it. | 153 | * that, when accepted, allow us to `cargo install cargo-watch` and then run it. |
154 | */ | 154 | */ |
155 | export async function interactivelyStartCargoWatch() { | 155 | export async function interactivelyStartCargoWatch() { |
156 | if (!Server.config.enableCargoWatchOnStartup) { | 156 | if (Server.config.enableCargoWatchOnStartup === 'disabled') { |
157 | return; | 157 | return; |
158 | } | 158 | } |
159 | 159 | ||
160 | const execPromise = util.promisify(child_process.exec); | 160 | if (Server.config.enableCargoWatchOnStartup === 'ask') { |
161 | 161 | const watch = await vscode.window.showInformationMessage( | |
162 | const watch = await vscode.window.showInformationMessage( | 162 | 'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)', |
163 | 'Start watching changes with cargo? (Executes `cargo watch`, provides inline diagnostics)', | 163 | 'yes', |
164 | 'yes', | 164 | 'no' |
165 | 'no' | 165 | ); |
166 | ); | 166 | if (watch === 'no') { |
167 | if (watch === 'no') { | 167 | return; |
168 | return; | 168 | } |
169 | } | 169 | } |
170 | 170 | ||
171 | const execPromise = util.promisify(child_process.exec); | ||
172 | |||
171 | const { stderr } = await execPromise('cargo watch --version').catch(e => e); | 173 | const { stderr } = await execPromise('cargo watch --version').catch(e => e); |
174 | |||
172 | if (stderr.includes('no such subcommand: `watch`')) { | 175 | if (stderr.includes('no such subcommand: `watch`')) { |
173 | const msg = | 176 | const msg = |
174 | 'The `cargo-watch` subcommand is not installed. Install? (takes ~1-2 minutes)'; | 177 | 'The `cargo-watch` subcommand is not installed. Install? (takes ~1-2 minutes)'; |
diff --git a/editors/code/src/config.ts b/editors/code/src/config.ts index d8795f3b0..420589068 100644 --- a/editors/code/src/config.ts +++ b/editors/code/src/config.ts | |||
@@ -4,12 +4,14 @@ import { Server } from './server'; | |||
4 | 4 | ||
5 | const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; | 5 | const RA_LSP_DEBUG = process.env.__RA_LSP_SERVER_DEBUG; |
6 | 6 | ||
7 | export type CargoWatchOptions = 'ask' | 'enabled' | 'disabled'; | ||
8 | |||
7 | export class Config { | 9 | export class Config { |
8 | public highlightingOn = true; | 10 | public highlightingOn = true; |
9 | public enableEnhancedTyping = true; | 11 | public enableEnhancedTyping = true; |
10 | public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server'; | 12 | public raLspServerPath = RA_LSP_DEBUG || 'ra_lsp_server'; |
11 | public showWorkspaceLoadedNotification = true; | 13 | public showWorkspaceLoadedNotification = true; |
12 | public enableCargoWatchOnStartup = true; | 14 | public enableCargoWatchOnStartup: CargoWatchOptions = 'ask'; |
13 | 15 | ||
14 | private prevEnhancedTyping: null | boolean = null; | 16 | private prevEnhancedTyping: null | boolean = null; |
15 | 17 | ||
@@ -71,9 +73,9 @@ export class Config { | |||
71 | } | 73 | } |
72 | 74 | ||
73 | if (config.has('enableCargoWatchOnStartup')) { | 75 | if (config.has('enableCargoWatchOnStartup')) { |
74 | this.enableCargoWatchOnStartup = config.get<boolean>( | 76 | this.enableCargoWatchOnStartup = config.get<CargoWatchOptions>( |
75 | 'enableCargoWatchOnStartup', | 77 | 'enableCargoWatchOnStartup', |
76 | true | 78 | 'ask' |
77 | ); | 79 | ); |
78 | } | 80 | } |
79 | } | 81 | } |