Skip to content

Commit 869d3d6

Browse files
authored
Add new option to insiders installExtension command to prevent bundle reinstalls (#16374)
1 parent 46fb826 commit 869d3d6

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

src/client/common/application/commands.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ interface ICommandNameWithoutArgumentTypeMapping {
6262
export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgumentTypeMapping {
6363
['vscode.openWith']: [Uri, string];
6464
['workbench.action.quickOpen']: [string];
65-
['workbench.extensions.installExtension']: [Uri | 'ms-python.python'];
65+
['workbench.extensions.installExtension']: [
66+
Uri | 'ms-python.python',
67+
{ installOnlyNewlyAddedFromExtensionPackVSIX?: boolean } | undefined,
68+
];
6669
['workbench.action.files.openFolder']: [];
6770
['workbench.action.openWorkspace']: [];
6871
['setContext']: [string, boolean] | ['python.vscode.channel', Channel];

src/client/common/installer/extensionBuildInstaller.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export class StableBuildInstaller implements IExtensionBuildInstaller {
2929
this.output.append(ExtensionChannels.installingStableMessage());
3030
await this.appShell.withProgressCustomIcon(Octicons.Installing, async (progress) => {
3131
progress.report({ message: ExtensionChannels.installingStableMessage() });
32-
return this.cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID);
32+
return this.cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID, {
33+
installOnlyNewlyAddedFromExtensionPackVSIX: true,
34+
});
3335
});
3436
this.output.appendLine(ExtensionChannels.installationCompleteMessage());
3537
}
@@ -51,7 +53,9 @@ export class InsidersBuildInstaller implements IExtensionBuildInstaller {
5153
this.output.append(ExtensionChannels.installingInsidersMessage());
5254
await this.appShell.withProgressCustomIcon(Octicons.Installing, async (progress) => {
5355
progress.report({ message: ExtensionChannels.installingInsidersMessage() });
54-
return this.cmdManager.executeCommand('workbench.extensions.installExtension', Uri.file(vsixFilePath));
56+
return this.cmdManager.executeCommand('workbench.extensions.installExtension', Uri.file(vsixFilePath), {
57+
installOnlyNewlyAddedFromExtensionPackVSIX: true,
58+
});
5559
});
5660
this.output.appendLine(ExtensionChannels.installationCompleteMessage());
5761
await this.fs.deleteFile(vsixFilePath);

src/test/common/installer/extensionBuildInstaller.unit.test.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@ suite('Extension build installer - Stable build installer', async () => {
4545
test('Installing stable build logs progress and installs stable', async () => {
4646
when(output.append(ExtensionChannels.installingStableMessage())).thenReturn();
4747
when(output.appendLine(ExtensionChannels.installationCompleteMessage())).thenReturn();
48-
when(cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID)).thenResolve(
49-
undefined,
50-
);
48+
when(
49+
cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID, anything()),
50+
).thenResolve(undefined);
5151
when(appShell.withProgressCustomIcon(anything(), anything())).thenCall((_, cb) => cb(progressReporter));
5252
await stableBuildInstaller.install();
5353
verify(output.append(ExtensionChannels.installingStableMessage())).once();
5454
verify(output.appendLine(ExtensionChannels.installationCompleteMessage())).once();
5555
verify(appShell.withProgressCustomIcon(anything(), anything()));
5656
expect(progressReportStub.callCount).to.equal(1);
57-
verify(cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID)).once();
57+
verify(
58+
cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID, anything()),
59+
).once();
5860
});
5961
});
6062

@@ -102,9 +104,12 @@ suite('Extension build installer - Insiders build installer', async () => {
102104
},
103105
);
104106
when(appShell.withProgressCustomIcon(anything(), anything())).thenCall((_, cb) => cb(progressReporter));
105-
when(cmdManager.executeCommand('workbench.extensions.installExtension', anything())).thenCall((_, cb) => {
106-
assert.deepEqual(cb, Uri.file(vsixFilePath), 'Wrong VSIX installed');
107-
});
107+
when(cmdManager.executeCommand('workbench.extensions.installExtension', anything(), anything())).thenCall(
108+
(_, uri, options) => {
109+
assert.deepStrictEqual(uri, Uri.file(vsixFilePath), 'Wrong VSIX installed');
110+
assert.deepStrictEqual(options, { installOnlyNewlyAddedFromExtensionPackVSIX: true });
111+
},
112+
);
108113
when(fs.deleteFile(vsixFilePath)).thenResolve();
109114

110115
await insidersBuildInstaller.install();
@@ -115,7 +120,7 @@ suite('Extension build installer - Insiders build installer', async () => {
115120
verify(output.appendLine(ExtensionChannels.installationCompleteMessage())).once();
116121
verify(appShell.withProgressCustomIcon(anything(), anything()));
117122
expect(progressReportStub.callCount).to.equal(1);
118-
verify(cmdManager.executeCommand('workbench.extensions.installExtension', anything())).once();
123+
verify(cmdManager.executeCommand('workbench.extensions.installExtension', anything(), anything())).once();
119124
verify(fs.deleteFile(vsixFilePath)).once();
120125
});
121126
});

0 commit comments

Comments
 (0)