aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r--editors/code/src/commands/cargo_watch.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/editors/code/src/commands/cargo_watch.ts b/editors/code/src/commands/cargo_watch.ts
index fb8fcaeb3..6d8e4d885 100644
--- a/editors/code/src/commands/cargo_watch.ts
+++ b/editors/code/src/commands/cargo_watch.ts
@@ -1,4 +1,5 @@
1import * as child_process from 'child_process'; 1import * as child_process from 'child_process';
2import * as fs from 'fs';
2import * as path from 'path'; 3import * as path from 'path';
3import * as vscode from 'vscode'; 4import * as vscode from 'vscode';
4import { Server } from '../server'; 5import { Server } from '../server';
@@ -14,6 +15,27 @@ export class CargoWatchProvider {
14 private outputChannel?: vscode.OutputChannel; 15 private outputChannel?: vscode.OutputChannel;
15 16
16 public activate(subscriptions: vscode.Disposable[]) { 17 public activate(subscriptions: vscode.Disposable[]) {
18 let cargoExists = false;
19 const cargoTomlFile = path.join(
20 vscode.workspace.rootPath!,
21 'Cargo.toml'
22 );
23 // Check if the working directory is valid cargo root path
24 try {
25 if (fs.existsSync(cargoTomlFile)) {
26 cargoExists = true;
27 }
28 } catch (err) {
29 cargoExists = false;
30 }
31
32 if (!cargoExists) {
33 vscode.window.showErrorMessage(
34 `Couldn\'t find \'Cargo.toml\' in ${cargoTomlFile}`
35 );
36 return;
37 }
38
17 subscriptions.push(this); 39 subscriptions.push(this);
18 this.diagnosticCollection = vscode.languages.createDiagnosticCollection( 40 this.diagnosticCollection = vscode.languages.createDiagnosticCollection(
19 'rustc' 41 'rustc'