From 422f4ac080c1347421a1ba6efcbc8f5b40414f46 Mon Sep 17 00:00:00 2001 From: Bernardo Date: Fri, 19 Apr 2019 18:28:14 +0200 Subject: start cargo watch if not started interactively --- editors/code/src/commands/runnables.ts | 12 +++++++++++- editors/code/src/extension.ts | 9 ++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'editors/code/src') 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( } } + return startCargoWatch(context); +} + +export async function startCargoWatch( + context: vscode.ExtensionContext +): Promise { const execPromise = util.promisify(child_process.exec); const { stderr } = await execPromise('cargo watch --version').catch(e => e); @@ -197,5 +203,9 @@ export async function interactivelyStartCargoWatch( } } - return registerCargoWatchProvider(context.subscriptions); + const provider = await registerCargoWatchProvider(context.subscriptions); + if (provider) { + provider.start(); + } + return provider; } 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'; import * as commands from './commands'; import { CargoWatchProvider } from './commands/cargo_watch'; -import { interactivelyStartCargoWatch } from './commands/runnables'; +import { + interactivelyStartCargoWatch, + startCargoWatch +} from './commands/runnables'; import { SyntaxTreeContentProvider } from './commands/syntaxTree'; import * as events from './events'; import * as notifications from './notifications'; @@ -134,6 +137,10 @@ export function activate(context: vscode.ExtensionContext) { registerCommand('rust-analyzer.startCargoWatch', () => { if (provider) { provider.start(); + } else { + startCargoWatch(context).then(p => { + provider = p; + }); } }); registerCommand('rust-analyzer.stopCargoWatch', () => { -- cgit v1.2.3