Skip to content

Commit 949e62a

Browse files
committed
fix: re-add version detection and fix it for Windows and Linux
1 parent 803af17 commit 949e62a

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ const moduleWrapper = tsserver => {
6161
//
6262
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
6363
//
64+
// Update 2021-10-08: VSCode changed their format in 1.61.
65+
// Before | ^zip:/c:/foo/bar.zip/package.json
66+
// After | ^/zip//c:/foo/bar.zip/package.json
67+
//
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+
//
72+
case `vscode <1.61`: {
73+
str = `^zip:${str}`;
74+
} break;
75+
76+
case `vscode <1.66`: {
77+
str = `^/zip/${str}`;
78+
} break;
79+
6480
case `vscode`: {
6581
str = `^/zip${str}`;
6682
} break;
@@ -152,6 +168,13 @@ const moduleWrapper = tsserver => {
152168
typeof parsedMessage.arguments.hostInfo === `string`
153169
) {
154170
hostInfo = parsedMessage.arguments.hostInfo;
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+
}
177+
}
155178
}
156179

157180
const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ const moduleWrapper = tsserver => {
6161
//
6262
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
6363
//
64+
// Update 2021-10-08: VSCode changed their format in 1.61.
65+
// Before | ^zip:/c:/foo/bar.zip/package.json
66+
// After | ^/zip//c:/foo/bar.zip/package.json
67+
//
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+
//
72+
case `vscode <1.61`: {
73+
str = `^zip:${str}`;
74+
} break;
75+
76+
case `vscode <1.66`: {
77+
str = `^/zip/${str}`;
78+
} break;
79+
6480
case `vscode`: {
6581
str = `^/zip${str}`;
6682
} break;
@@ -152,6 +168,13 @@ const moduleWrapper = tsserver => {
152168
typeof parsedMessage.arguments.hostInfo === `string`
153169
) {
154170
hostInfo = parsedMessage.arguments.hostInfo;
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+
}
177+
}
155178
}
156179

157180
const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi:
8888
//
8989
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
9090
//
91+
// Update 2021-10-08: VSCode changed their format in 1.61.
92+
// Before | ^zip:/c:/foo/bar.zip/package.json
93+
// After | ^/zip//c:/foo/bar.zip/package.json
94+
//
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+
//
99+
case \`vscode <1.61\`: {
100+
str = \`^zip:\${str}\`;
101+
} break;
102+
103+
case \`vscode <1.66\`: {
104+
str = \`^/zip/\${str}\`;
105+
} break;
106+
91107
case \`vscode\`: {
92108
str = \`^/zip\${str}\`;
93109
} break;
@@ -179,6 +195,13 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi:
179195
typeof parsedMessage.arguments.hostInfo === \`string\`
180196
) {
181197
hostInfo = parsedMessage.arguments.hostInfo;
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+
}
204+
}
182205
}
183206
184207
const processedMessageJSON = JSON.stringify(parsedMessage, (key, value) => {

0 commit comments

Comments
 (0)