提交 d1d1e651 编写于 作者: P Pine Wu

handle fs exceptions gracefully. fix #44506

上级 decbaecc
......@@ -77,13 +77,17 @@ export function providePathSuggestions(value: string, range: Range, activeDocFsP
const replaceRange = getReplaceRange(range, valueAfterLastSlash);
return fs.readdirSync(parentDir).map(f => {
return {
label: f,
kind: isDir(path.resolve(parentDir, f)) ? CompletionItemKind.Folder : CompletionItemKind.File,
textEdit: TextEdit.replace(replaceRange, f)
};
});
try {
return fs.readdirSync(parentDir).map(f => {
return {
label: f,
kind: isDir(path.resolve(parentDir, f)) ? CompletionItemKind.Folder : CompletionItemKind.File,
textEdit: TextEdit.replace(replaceRange, f)
};
});
} catch (e) {
return [];
}
}
const isDir = (p: string) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册