aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/code/package.json2
-rw-r--r--editors/code/src/commands/cargo_watch.ts21
2 files changed, 11 insertions, 12 deletions
diff --git a/editors/code/package.json b/editors/code/package.json
index 7a48d6794..38824acb4 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -13,7 +13,7 @@
13 "Other" 13 "Other"
14 ], 14 ],
15 "engines": { 15 "engines": {
16 "vscode": "^1.36.0" 16 "vscode": "^1.37.0"
17 }, 17 },
18 "scripts": { 18 "scripts": {
19 "vscode:prepublish": "npm run compile", 19 "vscode:prepublish": "npm run compile",
diff --git a/editors/code/src/commands/cargo_watch.ts b/editors/code/src/commands/cargo_watch.ts
index 4c3c10c8b..00b24dbce 100644
--- a/editors/code/src/commands/cargo_watch.ts
+++ b/editors/code/src/commands/cargo_watch.ts
@@ -1,5 +1,4 @@
1import * as child_process from 'child_process'; 1import * as child_process from 'child_process';
2import * as fs from 'fs';
3import * as path from 'path'; 2import * as path from 'path';
4import * as vscode from 'vscode'; 3import * as vscode from 'vscode';
5 4
@@ -15,23 +14,23 @@ import {
15import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection'; 14import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection';
16import { areDiagnosticsEqual } from '../utils/diagnostics/vscode'; 15import { areDiagnosticsEqual } from '../utils/diagnostics/vscode';
17 16
18export function registerCargoWatchProvider( 17export async function registerCargoWatchProvider(
19 subscriptions: vscode.Disposable[] 18 subscriptions: vscode.Disposable[]
20): CargoWatchProvider | undefined { 19): Promise<CargoWatchProvider | undefined> {
21 let cargoExists = false; 20 let cargoExists = false;
22 const cargoTomlFile = path.join(vscode.workspace.rootPath!, 'Cargo.toml'); 21
23 // Check if the working directory is valid cargo root path 22 // Check if the working directory is valid cargo root path
24 try { 23 const cargoTomlPath = path.join(vscode.workspace.rootPath!, 'Cargo.toml');
25 if (fs.existsSync(cargoTomlFile)) { 24 const cargoTomlUri = vscode.Uri.file(cargoTomlPath);
26 cargoExists = true; 25 const cargoTomlFileInfo = await vscode.workspace.fs.stat(cargoTomlUri);
27 } 26
28 } catch (err) { 27 if (cargoTomlFileInfo) {
29 cargoExists = false; 28 cargoExists = true;
30 } 29 }
31 30
32 if (!cargoExists) { 31 if (!cargoExists) {
33 vscode.window.showErrorMessage( 32 vscode.window.showErrorMessage(
34 `Couldn\'t find \'Cargo.toml\' in ${cargoTomlFile}` 33 `Couldn\'t find \'Cargo.toml\' at ${cargoTomlPath}`
35 ); 34 );
36 return; 35 return;
37 } 36 }