@volar/vscode 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,12 +28,12 @@ function activate(selector, cmd, context, client, resolveStatusText) {
28
28
  },
29
29
  useConfigWorkspaceTsdk: configTsdkPath && !vscodeTsdk.isWeb ? {
30
30
  label: (tsdk.isWorkspacePath ? '• ' : '') + 'Use Workspace Version',
31
- description: await getTsVersion(resolveWorkspaceTsdk(configTsdkPath) ?? '/') ?? 'Could not load the TypeScript version at this path',
31
+ description: await getTsVersion(await resolveWorkspaceTsdk(configTsdkPath) ?? '/') ?? 'Could not load the TypeScript version at this path',
32
32
  detail: configTsdkPath,
33
33
  } : undefined,
34
34
  useDefaultWorkspaceTsdk: configTsdkPath !== defaultTsdkPath && !vscodeTsdk.isWeb ? {
35
35
  label: (tsdk.isWorkspacePath ? '• ' : '') + 'Use Workspace Version',
36
- description: await getTsVersion(resolveWorkspaceTsdk(defaultTsdkPath) ?? '/') ?? 'Could not load the TypeScript version at this path',
36
+ description: await getTsVersion(await resolveWorkspaceTsdk(defaultTsdkPath) ?? '/') ?? 'Could not load the TypeScript version at this path',
37
37
  detail: defaultTsdkPath,
38
38
  } : undefined,
39
39
  },
@@ -81,7 +81,7 @@ function activate(selector, cmd, context, client, resolveStatusText) {
81
81
  exports.activate = activate;
82
82
  async function getTsdk(context) {
83
83
  if (isUseWorkspaceTsdk(context)) {
84
- const resolvedTsdk = resolveWorkspaceTsdk(getConfigTsdkPath() || defaultTsdkPath);
84
+ const resolvedTsdk = await resolveWorkspaceTsdk(getConfigTsdkPath() || defaultTsdkPath);
85
85
  if (resolvedTsdk) {
86
86
  return {
87
87
  tsdk: resolvedTsdk,
@@ -98,24 +98,22 @@ async function getTsdk(context) {
98
98
  };
99
99
  }
100
100
  exports.getTsdk = getTsdk;
101
- function resolveWorkspaceTsdk(tsdk) {
101
+ async function resolveWorkspaceTsdk(tsdk) {
102
102
  if (path.isAbsolute(tsdk)) {
103
- try {
104
- if (require.resolve('./typescript.js', { paths: [tsdk] })) {
105
- return tsdk;
106
- }
103
+ const libUri = vscode.Uri.joinPath(vscode.Uri.file(tsdk), 'typescript.js');
104
+ const stat = await vscode.workspace.fs.stat(libUri);
105
+ if (stat.type === vscode.FileType.File) {
106
+ return tsdk;
107
107
  }
108
- catch { }
109
108
  }
110
- if (vscode.workspace.workspaceFolders) {
109
+ else if (vscode.workspace.workspaceFolders) {
111
110
  for (const folder of vscode.workspace.workspaceFolders) {
112
111
  const tsdkPath = path.join(folder.uri.fsPath.replace(/\\/g, '/'), tsdk);
113
- try {
114
- if (require.resolve('./typescript.js', { paths: [tsdkPath] })) {
115
- return tsdkPath;
116
- }
112
+ const libUri = vscode.Uri.joinPath(vscode.Uri.file(tsdkPath), 'typescript.js');
113
+ const stat = await vscode.workspace.fs.stat(libUri);
114
+ if (stat.type === vscode.FileType.File) {
115
+ return tsdkPath;
117
116
  }
118
- catch { }
119
117
  }
120
118
  }
121
119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volar/vscode",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/vscode"
13
13
  },
14
14
  "dependencies": {
15
- "@volar/language-server": "2.1.0",
15
+ "@volar/language-server": "2.1.1",
16
16
  "path-browserify": "^1.0.1",
17
17
  "vscode-languageclient": "^9.0.1",
18
18
  "vscode-nls": "^5.2.0"
@@ -22,5 +22,5 @@
22
22
  "@types/path-browserify": "latest",
23
23
  "@types/vscode": "^1.82.0"
24
24
  },
25
- "gitHead": "09e1792f0adafb02caf89a5a45a6fcaaf3177808"
25
+ "gitHead": "e56916097fe7be2920aab6592a564a8e2ceafd14"
26
26
  }