Skip to content

Commit 39f6b0f

Browse files
authored
fix(sdks): update for VSCode 1.66 (#4330)
* fix(sdks): update for VSCode 1.66 * fix: re-add version detection and fix it for Windows and Linux
1 parent 2efb4d4 commit 39f6b0f

File tree

4 files changed

+54
-14
lines changed

4 files changed

+54
-14
lines changed

.yarn/sdks/typescript/lib/tsserver.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const moduleWrapper = tsserver => {
1818
const pnpApi = require(`pnpapi`);
1919

2020
const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
21+
const isPortal = str => str.startsWith("portal:/");
2122
const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
2223

2324
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
@@ -44,7 +45,7 @@ const moduleWrapper = tsserver => {
4445
const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
4546
if (resolved) {
4647
const locator = pnpApi.findPackageLocator(resolved);
47-
if (locator && dependencyTreeRoots.has(`${locator.name}@${locator.reference}`)) {
48+
if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) {
4849
str = resolved;
4950
}
5051
}
@@ -60,18 +61,26 @@ const moduleWrapper = tsserver => {
6061
//
6162
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
6263
//
63-
// Update Oct 8 2021: VSCode changed their format in 1.61.
64+
// Update 2021-10-08: VSCode changed their format in 1.61.
6465
// Before | ^zip:/c:/foo/bar.zip/package.json
6566
// After | ^/zip//c:/foo/bar.zip/package.json
6667
//
68+
// Update 2022-04-06: VSCode changed the format in 1.66.
69+
// Before | ^/zip//c:/foo/bar.zip/package.json
70+
// After | ^/zip/c:/foo/bar.zip/package.json
71+
//
6772
case `vscode <1.61`: {
6873
str = `^zip:${str}`;
6974
} break;
7075

71-
case `vscode`: {
76+
case `vscode <1.66`: {
7277
str = `^/zip/${str}`;
7378
} break;
7479

80+
case `vscode`: {
81+
str = `^/zip${str}`;
82+
} break;
83+
7584
// To make "go to definition" work,
7685
// We have to resolve the actual file system path from virtual path
7786
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
@@ -159,8 +168,12 @@ const moduleWrapper = tsserver => {
159168
typeof parsedMessage.arguments.hostInfo === `string`
160169
) {
161170
hostInfo = parsedMessage.arguments.hostInfo;
162-
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK && process.env.VSCODE_IPC_HOOK.match(/Code\/1\.([1-5][0-9]|60)\./)) {
163-
hostInfo += ` <1.61`;
171+
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
172+
if (/(\/|-)1\.([1-5][0-9]|60)\./.test(process.env.VSCODE_IPC_HOOK)) {
173+
hostInfo += ` <1.61`;
174+
} else if (/(\/|-)1\.(6[1-5])\./.test(process.env.VSCODE_IPC_HOOK)) {
175+
hostInfo += ` <1.66`;
176+
}
164177
}
165178
}
166179

.yarn/sdks/typescript/lib/tsserverlibrary.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const moduleWrapper = tsserver => {
1818
const pnpApi = require(`pnpapi`);
1919

2020
const isVirtual = str => str.match(/\/(\$\$virtual|__virtual__)\//);
21+
const isPortal = str => str.startsWith("portal:/");
2122
const normalize = str => str.replace(/\\/g, `/`).replace(/^\/?/, `/`);
2223

2324
const dependencyTreeRoots = new Set(pnpApi.getDependencyTreeRoots().map(locator => {
@@ -44,7 +45,7 @@ const moduleWrapper = tsserver => {
4445
const resolved = isVirtual(str) ? pnpApi.resolveVirtual(str) : str;
4546
if (resolved) {
4647
const locator = pnpApi.findPackageLocator(resolved);
47-
if (locator && dependencyTreeRoots.has(`${locator.name}@${locator.reference}`)) {
48+
if (locator && (dependencyTreeRoots.has(`${locator.name}@${locator.reference}`) || isPortal(locator.reference))) {
4849
str = resolved;
4950
}
5051
}
@@ -60,18 +61,26 @@ const moduleWrapper = tsserver => {
6061
//
6162
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
6263
//
63-
// Update Oct 8 2021: VSCode changed their format in 1.61.
64+
// Update 2021-10-08: VSCode changed their format in 1.61.
6465
// Before | ^zip:/c:/foo/bar.zip/package.json
6566
// After | ^/zip//c:/foo/bar.zip/package.json
6667
//
68+
// Update 2022-04-06: VSCode changed the format in 1.66.
69+
// Before | ^/zip//c:/foo/bar.zip/package.json
70+
// After | ^/zip/c:/foo/bar.zip/package.json
71+
//
6772
case `vscode <1.61`: {
6873
str = `^zip:${str}`;
6974
} break;
7075

71-
case `vscode`: {
76+
case `vscode <1.66`: {
7277
str = `^/zip/${str}`;
7378
} break;
7479

80+
case `vscode`: {
81+
str = `^/zip${str}`;
82+
} break;
83+
7584
// To make "go to definition" work,
7685
// We have to resolve the actual file system path from virtual path
7786
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
@@ -159,8 +168,12 @@ const moduleWrapper = tsserver => {
159168
typeof parsedMessage.arguments.hostInfo === `string`
160169
) {
161170
hostInfo = parsedMessage.arguments.hostInfo;
162-
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK && process.env.VSCODE_IPC_HOOK.match(/Code\/1\.([1-5][0-9]|60)\./)) {
163-
hostInfo += ` <1.61`;
171+
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
172+
if (/(\/|-)1\.([1-5][0-9]|60)\./.test(process.env.VSCODE_IPC_HOOK)) {
173+
hostInfo += ` <1.61`;
174+
} else if (/(\/|-)1\.(6[1-5])\./.test(process.env.VSCODE_IPC_HOOK)) {
175+
hostInfo += ` <1.66`;
176+
}
164177
}
165178
}
166179

.yarn/versions/4a257e90.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
releases:
2+
"@yarnpkg/sdks": patch

packages/yarnpkg-sdks/sources/sdks/base.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,26 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi:
8888
//
8989
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
9090
//
91-
// Update Oct 8 2021: VSCode changed their format in 1.61.
91+
// Update 2021-10-08: VSCode changed their format in 1.61.
9292
// Before | ^zip:/c:/foo/bar.zip/package.json
9393
// After | ^/zip//c:/foo/bar.zip/package.json
9494
//
95+
// Update 2022-04-06: VSCode changed the format in 1.66.
96+
// Before | ^/zip//c:/foo/bar.zip/package.json
97+
// After | ^/zip/c:/foo/bar.zip/package.json
98+
//
9599
case \`vscode <1.61\`: {
96100
str = \`^zip:\${str}\`;
97101
} break;
98102
99-
case \`vscode\`: {
103+
case \`vscode <1.66\`: {
100104
str = \`^/zip/\${str}\`;
101105
} break;
102106
107+
case \`vscode\`: {
108+
str = \`^/zip\${str}\`;
109+
} break;
110+
103111
// To make "go to definition" work,
104112
// We have to resolve the actual file system path from virtual path
105113
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
@@ -187,8 +195,12 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi:
187195
typeof parsedMessage.arguments.hostInfo === \`string\`
188196
) {
189197
hostInfo = parsedMessage.arguments.hostInfo;
190-
if (hostInfo === \`vscode\` && process.env.VSCODE_IPC_HOOK && process.env.VSCODE_IPC_HOOK.match(/Code\\/1\\.([1-5][0-9]|60)\\./)) {
191-
hostInfo += \` <1.61\`;
198+
if (hostInfo === \`vscode\` && process.env.VSCODE_IPC_HOOK) {
199+
if (/(\\/|-)1\\.([1-5][0-9]|60)\\./.test(process.env.VSCODE_IPC_HOOK)) {
200+
hostInfo += \` <1.61\`;
201+
} else if (/(\\/|-)1\\.(6[1-5])\\./.test(process.env.VSCODE_IPC_HOOK)) {
202+
hostInfo += \` <1.66\`;
203+
}
192204
}
193205
}
194206

0 commit comments

Comments
 (0)