Skip to content

Commit c1f675b

Browse files
committed
fix(sdks): update for VSCode 1.68 (#4485)
(cherry picked from commit beefef7)
1 parent 3874b17 commit c1f675b

File tree

4 files changed

+77
-30
lines changed

4 files changed

+77
-30
lines changed

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,18 @@ 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.
64+
// 2021-10-08: VSCode changed the format in 1.61.
6565
// Before | ^zip:/c:/foo/bar.zip/package.json
6666
// After | ^/zip//c:/foo/bar.zip/package.json
6767
//
68-
// Update 2022-04-06: VSCode changed the format in 1.66.
68+
// 2022-04-06: VSCode changed the format in 1.66.
6969
// Before | ^/zip//c:/foo/bar.zip/package.json
7070
// After | ^/zip/c:/foo/bar.zip/package.json
7171
//
72+
// 2022-05-06: VSCode changed the format in 1.68
73+
// Before | ^/zip/c:/foo/bar.zip/package.json
74+
// After | ^/zip//c:/foo/bar.zip/package.json
75+
//
7276
case `vscode <1.61`: {
7377
str = `^zip:${str}`;
7478
} break;
@@ -77,10 +81,14 @@ const moduleWrapper = tsserver => {
7781
str = `^/zip/${str}`;
7882
} break;
7983

80-
case `vscode`: {
84+
case `vscode <1.68`: {
8185
str = `^/zip${str}`;
8286
} break;
8387

88+
case `vscode`: {
89+
str = `^/zip/${str}`;
90+
} break;
91+
8492
// To make "go to definition" work,
8593
// We have to resolve the actual file system path from virtual path
8694
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
@@ -129,9 +137,7 @@ const moduleWrapper = tsserver => {
129137

130138
case `vscode`:
131139
default: {
132-
return process.platform === `win32`
133-
? str.replace(/^\^?(zip:|\/zip)\/+/, ``)
134-
: str.replace(/^\^?(zip:|\/zip)\/+/, `/`);
140+
return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
135141
} break;
136142
}
137143
}
@@ -171,10 +177,19 @@ const moduleWrapper = tsserver => {
171177
) {
172178
hostInfo = parsedMessage.arguments.hostInfo;
173179
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
174-
if (/(\/|-)1\.([1-5][0-9]|60)\./.test(process.env.VSCODE_IPC_HOOK)) {
175-
hostInfo += ` <1.61`;
176-
} else if (/(\/|-)1\.(6[1-5])\./.test(process.env.VSCODE_IPC_HOOK)) {
177-
hostInfo += ` <1.66`;
180+
const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
181+
// The RegExp from https://semver.org/ but without the caret at the start
182+
/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
183+
) ?? []).map(Number)
184+
185+
if (major === 1) {
186+
if (minor < 61) {
187+
hostInfo += ` <1.61`;
188+
} else if (minor < 66) {
189+
hostInfo += ` <1.66`;
190+
} else if (minor < 68) {
191+
hostInfo += ` <1.68`;
192+
}
178193
}
179194
}
180195
}

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

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,18 @@ 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.
64+
// 2021-10-08: VSCode changed the format in 1.61.
6565
// Before | ^zip:/c:/foo/bar.zip/package.json
6666
// After | ^/zip//c:/foo/bar.zip/package.json
6767
//
68-
// Update 2022-04-06: VSCode changed the format in 1.66.
68+
// 2022-04-06: VSCode changed the format in 1.66.
6969
// Before | ^/zip//c:/foo/bar.zip/package.json
7070
// After | ^/zip/c:/foo/bar.zip/package.json
7171
//
72+
// 2022-05-06: VSCode changed the format in 1.68
73+
// Before | ^/zip/c:/foo/bar.zip/package.json
74+
// After | ^/zip//c:/foo/bar.zip/package.json
75+
//
7276
case `vscode <1.61`: {
7377
str = `^zip:${str}`;
7478
} break;
@@ -77,10 +81,14 @@ const moduleWrapper = tsserver => {
7781
str = `^/zip/${str}`;
7882
} break;
7983

80-
case `vscode`: {
84+
case `vscode <1.68`: {
8185
str = `^/zip${str}`;
8286
} break;
8387

88+
case `vscode`: {
89+
str = `^/zip/${str}`;
90+
} break;
91+
8492
// To make "go to definition" work,
8593
// We have to resolve the actual file system path from virtual path
8694
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
@@ -129,9 +137,7 @@ const moduleWrapper = tsserver => {
129137

130138
case `vscode`:
131139
default: {
132-
return process.platform === `win32`
133-
? str.replace(/^\^?(zip:|\/zip)\/+/, ``)
134-
: str.replace(/^\^?(zip:|\/zip)\/+/, `/`);
140+
return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
135141
} break;
136142
}
137143
}
@@ -171,10 +177,19 @@ const moduleWrapper = tsserver => {
171177
) {
172178
hostInfo = parsedMessage.arguments.hostInfo;
173179
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
174-
if (/(\/|-)1\.([1-5][0-9]|60)\./.test(process.env.VSCODE_IPC_HOOK)) {
175-
hostInfo += ` <1.61`;
176-
} else if (/(\/|-)1\.(6[1-5])\./.test(process.env.VSCODE_IPC_HOOK)) {
177-
hostInfo += ` <1.66`;
180+
const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
181+
// The RegExp from https://semver.org/ but without the caret at the start
182+
/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
183+
) ?? []).map(Number)
184+
185+
if (major === 1) {
186+
if (minor < 61) {
187+
hostInfo += ` <1.61`;
188+
} else if (minor < 66) {
189+
hostInfo += ` <1.66`;
190+
} else if (minor < 68) {
191+
hostInfo += ` <1.68`;
192+
}
178193
}
179194
}
180195
}

.yarn/versions/0d403b34.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: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,18 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi:
9898
//
9999
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
100100
//
101-
// Update 2021-10-08: VSCode changed their format in 1.61.
101+
// 2021-10-08: VSCode changed the format in 1.61.
102102
// Before | ^zip:/c:/foo/bar.zip/package.json
103103
// After | ^/zip//c:/foo/bar.zip/package.json
104104
//
105-
// Update 2022-04-06: VSCode changed the format in 1.66.
105+
// 2022-04-06: VSCode changed the format in 1.66.
106106
// Before | ^/zip//c:/foo/bar.zip/package.json
107107
// After | ^/zip/c:/foo/bar.zip/package.json
108108
//
109+
// 2022-05-06: VSCode changed the format in 1.68
110+
// Before | ^/zip/c:/foo/bar.zip/package.json
111+
// After | ^/zip//c:/foo/bar.zip/package.json
112+
//
109113
case \`vscode <1.61\`: {
110114
str = \`^zip:\${str}\`;
111115
} break;
@@ -114,10 +118,14 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi:
114118
str = \`^/zip/\${str}\`;
115119
} break;
116120
117-
case \`vscode\`: {
121+
case \`vscode <1.68\`: {
118122
str = \`^/zip\${str}\`;
119123
} break;
120124
125+
case \`vscode\`: {
126+
str = \`^/zip/\${str}\`;
127+
} break;
128+
121129
// To make "go to definition" work,
122130
// We have to resolve the actual file system path from virtual path
123131
// and convert scheme to supported by [vim-rzip](https://github.com/lbrayner/vim-rzip)
@@ -166,9 +174,7 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi:
166174
167175
case \`vscode\`:
168176
default: {
169-
return process.platform === \`win32\`
170-
? str.replace(/^\\^?(zip:|\\/zip)\\/+/, \`\`)
171-
: str.replace(/^\\^?(zip:|\\/zip)\\/+/, \`/\`);
177+
return str.replace(/^\\^?(zip:|\\/zip(\\/ts-nul-authority)?)\\/+/, process.platform === \`win32\` ? \`\` : \`/\`)
172178
} break;
173179
}
174180
}
@@ -208,10 +214,19 @@ export const generateTypescriptBaseWrapper: GenerateBaseWrapper = async (pnpApi:
208214
) {
209215
hostInfo = parsedMessage.arguments.hostInfo;
210216
if (hostInfo === \`vscode\` && process.env.VSCODE_IPC_HOOK) {
211-
if (/(\\/|-)1\\.([1-5][0-9]|60)\\./.test(process.env.VSCODE_IPC_HOOK)) {
212-
hostInfo += \` <1.61\`;
213-
} else if (/(\\/|-)1\\.(6[1-5])\\./.test(process.env.VSCODE_IPC_HOOK)) {
214-
hostInfo += \` <1.66\`;
217+
const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
218+
// The RegExp from https://semver.org/ but without the caret at the start
219+
/(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/
220+
) ?? []).map(Number)
221+
222+
if (major === 1) {
223+
if (minor < 61) {
224+
hostInfo += \` <1.61\`;
225+
} else if (minor < 66) {
226+
hostInfo += \` <1.66\`;
227+
} else if (minor < 68) {
228+
hostInfo += \` <1.68\`;
229+
}
215230
}
216231
}
217232
}

0 commit comments

Comments
 (0)