Avoid sync stat call
This commit is contained in:
parent
4d81d14de0
commit
1bccbd1cb6
1 changed files with 12 additions and 1 deletions
|
@ -22,6 +22,17 @@ const localize = nls.loadMessageBundle();
|
|||
|
||||
const updateImportsOnFileMoveName = 'updateImportsOnFileMove.enabled';
|
||||
|
||||
function isDirectory(path: string): Promise<boolean> {
|
||||
return new Promise<boolean>((resolve, reject) => {
|
||||
fs.stat(path, (err, stat) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
return resolve(stat.isDirectory());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
enum UpdateImportsOnFileMoveSetting {
|
||||
Prompt = 'prompt',
|
||||
Always = 'always',
|
||||
|
@ -185,7 +196,7 @@ class UpdateImportsOnFileRenameHandler extends Disposable {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
if (fs.lstatSync(resource.fsPath).isDirectory()) {
|
||||
if (await isDirectory(resource.fsPath)) {
|
||||
const files = await vscode.workspace.findFiles({
|
||||
base: resource.fsPath,
|
||||
pattern: '**/*.{ts,tsx,js,jsx}',
|
||||
|
|
Loading…
Reference in a new issue