Skip to content

Commit 0e94a98

Browse files
committed
fix: rollback to vscode tsdk if failed to load workspace tsdk
close #1942
1 parent 51de991 commit 0e94a98

File tree

1 file changed

+6
-4
lines changed
  • extensions/vscode-vue-language-features/src/features

1 file changed

+6
-4
lines changed

extensions/vscode-vue-language-features/src/features/tsVersion.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function register(cmd: string, context: vscode.ExtensionContext, cl
4848
return;
4949
}
5050
if (select === 'use_workspace_tsdk_deafult') {
51-
vscode.workspace.getConfiguration('typescript').update('tsdk', defaultTsdk);
51+
await vscode.workspace.getConfiguration('typescript').update('tsdk', defaultTsdk);
5252
}
5353
const shouldUseWorkspaceTsdk = select !== 'use_vscode_tsdk';
5454
if (shouldUseWorkspaceTsdk !== useWorkspaceTsdk(context)) {
@@ -123,9 +123,11 @@ function resolveConfigTsdk(tsdk: path.OsPath | path.PosixPath) {
123123
const workspaceFolderFsPaths = (vscode.workspace.workspaceFolders ?? []).map(folder => folder.uri.fsPath as path.OsPath);
124124
for (const folder of workspaceFolderFsPaths) {
125125
const _path = path.join(folder, tsdk);
126-
if (fs.existsSync(_path)) {
127-
return _path;
128-
}
126+
try {
127+
if (require.resolve('./typescript.js', { paths: [_path] })) {
128+
return _path;
129+
}
130+
} catch { }
129131
}
130132
}
131133

0 commit comments

Comments
 (0)