From caadaeaf5516048ec05625ad70e39825a1fed9a1 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 23 Feb 2023 15:48:37 -0800 Subject: [PATCH] Update proposed APIs --- package.json | 1 + .../application/applicationEnvironment.ts | 14 +++++--------- src/client/common/application/types.ts | 4 ++++ src/client/interpreter/activation/service.ts | 7 ++++++- types/vscode.proposed.envShellEvent.d.ts | 16 ++++++++++++++++ types/vscode.proposed.testObserver.d.ts | 18 ------------------ 6 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 types/vscode.proposed.envShellEvent.d.ts diff --git a/package.json b/package.json index 5e07893bf3d88..d81292db9e170 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ "publisher": "ms-python", "enabledApiProposals": [ "quickPickSortByLabel", + "envShellEvent", "testObserver" ], "author": { diff --git a/src/client/common/application/applicationEnvironment.ts b/src/client/common/application/applicationEnvironment.ts index e3d78477996d5..cf5e13d5ecaff 100644 --- a/src/client/common/application/applicationEnvironment.ts +++ b/src/client/common/application/applicationEnvironment.ts @@ -70,19 +70,15 @@ export class ApplicationEnvironment implements IApplicationEnvironment { public get extensionName(): string { return this.packageJson.displayName; } - /** - * At the time of writing this API, the vscode.env.shell isn't officially released in stable version of VS Code. - * Using this in stable version seems to throw errors in VSC with messages being displayed to the user about use of - * unstable API. - * Solution - log and suppress the errors. - * @readonly - * @type {(string)} - * @memberof ApplicationEnvironment - */ + public get shell(): string { return vscode.env.shell; } + public get onDidChangeShell(): vscode.Event { + return vscode.env.onDidChangeShell; + } + public get packageJson(): any { return require('../../../../package.json'); } diff --git a/src/client/common/application/types.ts b/src/client/common/application/types.ts index 69caf30a261b2..1b054eda687ca 100644 --- a/src/client/common/application/types.ts +++ b/src/client/common/application/types.ts @@ -1048,6 +1048,10 @@ export interface IApplicationEnvironment { * @memberof IApplicationShell */ readonly shell: string; + /** + * An {@link Event} which fires when the default shell changes. + */ + readonly onDidChangeShell: Event; /** * Gets the vscode channel (whether 'insiders' or 'stable'). */ diff --git a/src/client/interpreter/activation/service.ts b/src/client/interpreter/activation/service.ts index f8c7e7727cacd..d660c7ef3def7 100644 --- a/src/client/interpreter/activation/service.ts +++ b/src/client/interpreter/activation/service.ts @@ -163,6 +163,11 @@ export class EnvironmentActivationService this, this.disposables, ); + this.applicationEnvironment.onDidChangeShell( + () => this.applyCollectionForSelectedShell(), + this, + this.disposables, + ); this.initializeCollection(undefined).ignoreErrors(); } @@ -248,7 +253,7 @@ export class EnvironmentActivationService args[i] = arg.toCommandArgumentForPythonExt(); }); if (interpreter?.envType === EnvironmentType.Conda) { - const conda = await Conda.getConda(); + const conda = await Conda.getConda(shell); const pythonArgv = await conda?.getRunPythonArgs({ name: interpreter.envName, prefix: interpreter.envPath ?? '', diff --git a/types/vscode.proposed.envShellEvent.d.ts b/types/vscode.proposed.envShellEvent.d.ts new file mode 100644 index 0000000000000..8fed971ef7113 --- /dev/null +++ b/types/vscode.proposed.envShellEvent.d.ts @@ -0,0 +1,16 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + + // See https://github.com/microsoft/vscode/issues/160694 + export namespace env { + + /** + * An {@link Event} which fires when the default shell changes. + */ + export const onDidChangeShell: Event; + } +} diff --git a/types/vscode.proposed.testObserver.d.ts b/types/vscode.proposed.testObserver.d.ts index 2bdb21d74732e..d4465affbf2ff 100644 --- a/types/vscode.proposed.testObserver.d.ts +++ b/types/vscode.proposed.testObserver.d.ts @@ -68,24 +68,6 @@ declare module 'vscode' { readonly removed: ReadonlyArray; } - /** - * A test item is an item shown in the "test explorer" view. It encompasses - * both a suite and a test, since they have almost or identical capabilities. - */ - export interface TestItem { - /** - * Marks the test as outdated. This can happen as a result of file changes, - * for example. In "auto run" mode, tests that are outdated will be - * automatically rerun after a short delay. Invoking this on a - * test with children will mark the entire subtree as outdated. - * - * Extensions should generally not override this method. - */ - // todo@api still unsure about this - invalidateResults(): void; - } - - /** * TestResults can be provided to the editor in {@link tests.publishTestResult}, * or read from it in {@link tests.testResults}.