diff --git a/src/client/common/application/commands.ts b/src/client/common/application/commands.ts index 31ad3eba7e47..14585f36dfb4 100644 --- a/src/client/common/application/commands.ts +++ b/src/client/common/application/commands.ts @@ -62,7 +62,10 @@ interface ICommandNameWithoutArgumentTypeMapping { export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgumentTypeMapping { ['vscode.openWith']: [Uri, string]; ['workbench.action.quickOpen']: [string]; - ['workbench.extensions.installExtension']: [Uri | 'ms-python.python']; + ['workbench.extensions.installExtension']: [ + Uri | 'ms-python.python', + { installOnlyNewlyAddedFromExtensionPackVSIX?: boolean } | undefined, + ]; ['workbench.action.files.openFolder']: []; ['workbench.action.openWorkspace']: []; ['setContext']: [string, boolean] | ['python.vscode.channel', Channel]; diff --git a/src/client/common/installer/extensionBuildInstaller.ts b/src/client/common/installer/extensionBuildInstaller.ts index 984578e1bc4d..cd93040877fb 100644 --- a/src/client/common/installer/extensionBuildInstaller.ts +++ b/src/client/common/installer/extensionBuildInstaller.ts @@ -29,7 +29,9 @@ export class StableBuildInstaller implements IExtensionBuildInstaller { this.output.append(ExtensionChannels.installingStableMessage()); await this.appShell.withProgressCustomIcon(Octicons.Installing, async (progress) => { progress.report({ message: ExtensionChannels.installingStableMessage() }); - return this.cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID); + return this.cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID, { + installOnlyNewlyAddedFromExtensionPackVSIX: true, + }); }); this.output.appendLine(ExtensionChannels.installationCompleteMessage()); } @@ -51,7 +53,9 @@ export class InsidersBuildInstaller implements IExtensionBuildInstaller { this.output.append(ExtensionChannels.installingInsidersMessage()); await this.appShell.withProgressCustomIcon(Octicons.Installing, async (progress) => { progress.report({ message: ExtensionChannels.installingInsidersMessage() }); - return this.cmdManager.executeCommand('workbench.extensions.installExtension', Uri.file(vsixFilePath)); + return this.cmdManager.executeCommand('workbench.extensions.installExtension', Uri.file(vsixFilePath), { + installOnlyNewlyAddedFromExtensionPackVSIX: true, + }); }); this.output.appendLine(ExtensionChannels.installationCompleteMessage()); await this.fs.deleteFile(vsixFilePath); diff --git a/src/test/common/installer/extensionBuildInstaller.unit.test.ts b/src/test/common/installer/extensionBuildInstaller.unit.test.ts index 56a8d86d91ef..c69ea5fefaff 100644 --- a/src/test/common/installer/extensionBuildInstaller.unit.test.ts +++ b/src/test/common/installer/extensionBuildInstaller.unit.test.ts @@ -45,16 +45,18 @@ suite('Extension build installer - Stable build installer', async () => { test('Installing stable build logs progress and installs stable', async () => { when(output.append(ExtensionChannels.installingStableMessage())).thenReturn(); when(output.appendLine(ExtensionChannels.installationCompleteMessage())).thenReturn(); - when(cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID)).thenResolve( - undefined, - ); + when( + cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID, anything()), + ).thenResolve(undefined); when(appShell.withProgressCustomIcon(anything(), anything())).thenCall((_, cb) => cb(progressReporter)); await stableBuildInstaller.install(); verify(output.append(ExtensionChannels.installingStableMessage())).once(); verify(output.appendLine(ExtensionChannels.installationCompleteMessage())).once(); verify(appShell.withProgressCustomIcon(anything(), anything())); expect(progressReportStub.callCount).to.equal(1); - verify(cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID)).once(); + verify( + cmdManager.executeCommand('workbench.extensions.installExtension', PVSC_EXTENSION_ID, anything()), + ).once(); }); }); @@ -102,9 +104,12 @@ suite('Extension build installer - Insiders build installer', async () => { }, ); when(appShell.withProgressCustomIcon(anything(), anything())).thenCall((_, cb) => cb(progressReporter)); - when(cmdManager.executeCommand('workbench.extensions.installExtension', anything())).thenCall((_, cb) => { - assert.deepEqual(cb, Uri.file(vsixFilePath), 'Wrong VSIX installed'); - }); + when(cmdManager.executeCommand('workbench.extensions.installExtension', anything(), anything())).thenCall( + (_, uri, options) => { + assert.deepStrictEqual(uri, Uri.file(vsixFilePath), 'Wrong VSIX installed'); + assert.deepStrictEqual(options, { installOnlyNewlyAddedFromExtensionPackVSIX: true }); + }, + ); when(fs.deleteFile(vsixFilePath)).thenResolve(); await insidersBuildInstaller.install(); @@ -115,7 +120,7 @@ suite('Extension build installer - Insiders build installer', async () => { verify(output.appendLine(ExtensionChannels.installationCompleteMessage())).once(); verify(appShell.withProgressCustomIcon(anything(), anything())); expect(progressReportStub.callCount).to.equal(1); - verify(cmdManager.executeCommand('workbench.extensions.installExtension', anything())).once(); + verify(cmdManager.executeCommand('workbench.extensions.installExtension', anything(), anything())).once(); verify(fs.deleteFile(vsixFilePath)).once(); }); });