diff options
-rw-r--r-- | editors/code/src/commands/cargo_watch.ts | 22 |
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 @@ | |||
1 | import * as child_process from 'child_process'; | 1 | import * as child_process from 'child_process'; |
2 | import * as fs from 'fs'; | ||
2 | import * as path from 'path'; | 3 | import * as path from 'path'; |
3 | import * as vscode from 'vscode'; | 4 | import * as vscode from 'vscode'; |
4 | import { Server } from '../server'; | 5 | import { 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' |