aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/commands/runnables.ts12
-rw-r--r--editors/code/src/extension.ts9
2 files changed, 19 insertions, 2 deletions
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
159export 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
4import * as commands from './commands'; 4import * as commands from './commands';
5import { CargoWatchProvider } from './commands/cargo_watch'; 5import { CargoWatchProvider } from './commands/cargo_watch';
6import { interactivelyStartCargoWatch } from './commands/runnables'; 6import {
7 interactivelyStartCargoWatch,
8 startCargoWatch
9} from './commands/runnables';
7import { SyntaxTreeContentProvider } from './commands/syntaxTree'; 10import { SyntaxTreeContentProvider } from './commands/syntaxTree';
8import * as events from './events'; 11import * as events from './events';
9import * as notifications from './notifications'; 12import * 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', () => {