aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-09-11 10:59:04 +0100
committerGitHub <[email protected]>2019-09-11 10:59:04 +0100
commit7bbb039fbdd124cb6549eb67bbe7316f03ff40e8 (patch)
tree1826ee317c28a76b78f4020f9379c556339af803 /editors/code/src/commands
parent92800961a03501f24c661bbb093e5078f504214d (diff)
parent934d7990fd5bf87d858acb296c8f13909e770fda (diff)
Merge #1797
1797: Use VSCode fs API's in extension r=matklad a=LDSpits This will close #1670. I've replaced the `CargoWatcher`s `Cargo.toml` check with a version that uses the `fs` API of vscode. While making this I've identified an issue with the detection of the `cargo.toml`, we can only load projects where the cargo.toml is in the root of the workspace. but that's a separate issue 😄 Co-authored-by: Lucas Spits <[email protected]>
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r--editors/code/src/commands/cargo_watch.ts21
1 files changed, 10 insertions, 11 deletions
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 }