diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-20 15:02:36 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-20 15:02:36 +0100 |
commit | 526a6aba104a32eb9f0f5a65232783d5570c35d5 (patch) | |
tree | f8f6687924cb15a2d759dae02205b7f28a5f83fd /editors/code/src/commands/runnables.ts | |
parent | 0d39b1c3fa03a8032ea96be922fd62710f811aba (diff) | |
parent | 4cd0a96c96870d4e9a73b92f401a8fad26f3c02a (diff) |
Merge #1174
1174: improve cargo watch r=matklad a=vemoo
- Add start and stop commands
- Cleanup trypescript code to avoid definite assignment assertions (`!` after possibly undefined value)
- Recover `rustc-watch` problem matcher because it's still useful, can be used with any command, for example `cargo test`
Co-authored-by: Bernardo <[email protected]>
Diffstat (limited to 'editors/code/src/commands/runnables.ts')
-rw-r--r-- | editors/code/src/commands/runnables.ts | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/editors/code/src/commands/runnables.ts b/editors/code/src/commands/runnables.ts index c4df24c79..26372c1e8 100644 --- a/editors/code/src/commands/runnables.ts +++ b/editors/code/src/commands/runnables.ts | |||
@@ -5,7 +5,7 @@ import * as vscode from 'vscode'; | |||
5 | import * as lc from 'vscode-languageclient'; | 5 | import * as lc from 'vscode-languageclient'; |
6 | 6 | ||
7 | import { Server } from '../server'; | 7 | import { Server } from '../server'; |
8 | import { CargoWatchProvider } from './cargo_watch'; | 8 | import { CargoWatchProvider, registerCargoWatchProvider } from './cargo_watch'; |
9 | 9 | ||
10 | interface RunnablesParams { | 10 | interface RunnablesParams { |
11 | textDocument: lc.TextDocumentIdentifier; | 11 | textDocument: lc.TextDocumentIdentifier; |
@@ -137,7 +137,7 @@ export async function handleSingle(runnable: Runnable) { | |||
137 | */ | 137 | */ |
138 | export async function interactivelyStartCargoWatch( | 138 | export async function interactivelyStartCargoWatch( |
139 | context: vscode.ExtensionContext | 139 | context: vscode.ExtensionContext |
140 | ) { | 140 | ): Promise<CargoWatchProvider | undefined> { |
141 | if (Server.config.cargoWatchOptions.enableOnStartup === 'disabled') { | 141 | if (Server.config.cargoWatchOptions.enableOnStartup === 'disabled') { |
142 | return; | 142 | return; |
143 | } | 143 | } |
@@ -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,6 +203,9 @@ export async function interactivelyStartCargoWatch( | |||
197 | } | 203 | } |
198 | } | 204 | } |
199 | 205 | ||
200 | const validater = new CargoWatchProvider(); | 206 | const provider = await registerCargoWatchProvider(context.subscriptions); |
201 | validater.activate(context.subscriptions); | 207 | if (provider) { |
208 | provider.start(); | ||
209 | } | ||
210 | return provider; | ||
202 | } | 211 | } |