mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-22 19:34:16 +00:00
Replace watcher file existence check with vscode.fs version
This commit is contained in:
parent
7258523a51
commit
80b45d5928
1 changed files with 10 additions and 11 deletions
|
@ -1,5 +1,4 @@
|
||||||
import * as child_process from 'child_process';
|
import * as child_process from 'child_process';
|
||||||
import * as fs from 'fs';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
|
|
||||||
|
@ -15,23 +14,23 @@ import {
|
||||||
import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection';
|
import SuggestedFixCollection from '../utils/diagnostics/SuggestedFixCollection';
|
||||||
import { areDiagnosticsEqual } from '../utils/diagnostics/vscode';
|
import { areDiagnosticsEqual } from '../utils/diagnostics/vscode';
|
||||||
|
|
||||||
export function registerCargoWatchProvider(
|
export async function registerCargoWatchProvider(
|
||||||
subscriptions: vscode.Disposable[]
|
subscriptions: vscode.Disposable[]
|
||||||
): CargoWatchProvider | undefined {
|
): Promise<CargoWatchProvider | undefined> {
|
||||||
let cargoExists = false;
|
let cargoExists = false;
|
||||||
const cargoTomlFile = path.join(vscode.workspace.rootPath!, 'Cargo.toml');
|
|
||||||
// Check if the working directory is valid cargo root path
|
// Check if the working directory is valid cargo root path
|
||||||
try {
|
const cargoTomlPath = path.join(vscode.workspace.rootPath!, 'Cargo.toml');
|
||||||
if (fs.existsSync(cargoTomlFile)) {
|
const cargoTomlUri = vscode.Uri.file(cargoTomlPath);
|
||||||
cargoExists = true;
|
const cargoTomlFileInfo = await vscode.workspace.fs.stat(cargoTomlUri);
|
||||||
}
|
|
||||||
} catch (err) {
|
if (cargoTomlFileInfo) {
|
||||||
cargoExists = false;
|
cargoExists = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cargoExists) {
|
if (!cargoExists) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
`Couldn\'t find \'Cargo.toml\' in ${cargoTomlFile}`
|
`Couldn\'t find \'Cargo.toml\' at ${cargoTomlPath}`
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue