mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
fix: clean-up #8951
This commit is contained in:
parent
7a8a72c38f
commit
56e128a979
3 changed files with 25 additions and 15 deletions
|
@ -159,7 +159,7 @@ export const getPathForExecutable = memoize(
|
|||
// it is not mentioned in docs and cannot be infered by the type signature...
|
||||
const standardPath = vscode.Uri.joinPath(vscode.Uri.file(os.homedir()), ".cargo", "bin", executableName);
|
||||
|
||||
if (isFile(standardPath.path)) return standardPath.path;
|
||||
if (isFileAtUri(standardPath)) return standardPath.fsPath;
|
||||
} catch (err) {
|
||||
log.error("Failed to read the fs info", err);
|
||||
}
|
||||
|
@ -177,9 +177,17 @@ function lookupInPath(exec: string): boolean {
|
|||
: [candidate];
|
||||
});
|
||||
|
||||
return candidates.some(isFile);
|
||||
return candidates.some(isFileAtPath);
|
||||
}
|
||||
|
||||
async function isFile(path: string): Promise<boolean> {
|
||||
return ((await vscode.workspace.fs.stat(vscode.Uri.file(path))).type & vscode.FileType.File) !== 0;
|
||||
async function isFileAtPath(path: string): Promise<boolean> {
|
||||
return isFileAtUri(vscode.Uri.file(path));
|
||||
}
|
||||
|
||||
async function isFileAtUri(uri: vscode.Uri): Promise<boolean> {
|
||||
try {
|
||||
return ((await vscode.workspace.fs.stat(uri)).type & vscode.FileType.File) !== 0;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue