diff options
author | Bernardo <[email protected]> | 2019-04-19 17:28:14 +0100 |
---|---|---|
committer | Bernardo <[email protected]> | 2019-04-19 19:54:36 +0100 |
commit | 422f4ac080c1347421a1ba6efcbc8f5b40414f46 (patch) | |
tree | 01c72b5c48746b5dfb9b1155375cb86c631f7290 | |
parent | 3d3adabbef9290097fd890218d5d8ea6c1d8c002 (diff) |
start cargo watch if not started interactively
-rw-r--r-- | editors/code/package.json | 2 | ||||
-rw-r--r-- | editors/code/src/commands/runnables.ts | 12 | ||||
-rw-r--r-- | editors/code/src/extension.ts | 9 |
3 files changed, 20 insertions, 3 deletions
diff --git a/editors/code/package.json b/editors/code/package.json index dd9843241..83ceb19f7 100644 --- a/editors/code/package.json +++ b/editors/code/package.json | |||
@@ -275,4 +275,4 @@ | |||
275 | } | 275 | } |
276 | ] | 276 | ] |
277 | } | 277 | } |
278 | } \ No newline at end of file | 278 | } |
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index 5790252b7..26372c1e8 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts | |||
@@ -153,6 +153,12 @@ export async function interactivelyStartCargoWatch( | |||
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | return startCargoWatch(context); | ||
157 | } | ||
158 | |||
159 | export async function startCargoWatch( | ||
160 | context: vscode.ExtensionContext | ||
161 | ): Promise<CargoWatchProvider | undefined> { | ||
156 | const execPromise = util.promisify(child_process.exec); | 162 | const execPromise = util.promisify(child_process.exec); |
157 | 163 | ||
158 | const { stderr } = await execPromise('cargo watch --version').catch(e => e); | 164 | const { stderr } = await execPromise('cargo watch --version').catch(e => e); |
@@ -197,5 +203,9 @@ export async function interactivelyStartCargoWatch( | |||
197 | } | 203 | } |
198 | } | 204 | } |
199 | 205 | ||
200 | return registerCargoWatchProvider(context.subscriptions); | 206 | const provider = await registerCargoWatchProvider(context.subscriptions); |
207 | if (provider) { | ||
208 | provider.start(); | ||
209 | } | ||
210 | return provider; | ||
201 | } | 211 | } |
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index b48ad9b29..48dd2a614 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts | |||
@@ -3,7 +3,10 @@ import * as lc from 'vscode-languageclient'; | |||
3 | 3 | ||
4 | import * as commands from './commands'; | 4 | import * as commands from './commands'; |
5 | import { CargoWatchProvider } from './commands/cargo_watch'; | 5 | import { CargoWatchProvider } from './commands/cargo_watch'; |
6 | import { interactivelyStartCargoWatch } from './commands/runnables'; | 6 | import { |
7 | interactivelyStartCargoWatch, | ||
8 | startCargoWatch | ||
9 | } from './commands/runnables'; | ||
7 | import { SyntaxTreeContentProvider } from './commands/syntaxTree'; | 10 | import { SyntaxTreeContentProvider } from './commands/syntaxTree'; |
8 | import * as events from './events'; | 11 | import * as events from './events'; |
9 | import * as notifications from './notifications'; | 12 | import * as notifications from './notifications'; |
@@ -134,6 +137,10 @@ export function activate(context: vscode.ExtensionContext) { | |||
134 | registerCommand('rust-analyzer.startCargoWatch', () => { | 137 | registerCommand('rust-analyzer.startCargoWatch', () => { |
135 | if (provider) { | 138 | if (provider) { |
136 | provider.start(); | 139 | provider.start(); |
140 | } else { | ||
141 | startCargoWatch(context).then(p => { | ||
142 | provider = p; | ||
143 | }); | ||
137 | } | 144 | } |
138 | }); | 145 | }); |
139 | registerCommand('rust-analyzer.stopCargoWatch', () => { | 146 | registerCommand('rust-analyzer.stopCargoWatch', () => { |