Skip to content

Commit

Permalink
Update proposed APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Feb 24, 2023
1 parent afeedd8 commit caadaea
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 28 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"publisher": "ms-python",
"enabledApiProposals": [
"quickPickSortByLabel",
"envShellEvent",
"testObserver"
],
"author": {
Expand Down
14 changes: 5 additions & 9 deletions src/client/common/application/applicationEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
return vscode.env.onDidChangeShell;
}

public get packageJson(): any {
return require('../../../../package.json');
}
Expand Down
4 changes: 4 additions & 0 deletions src/client/common/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>;
/**
* Gets the vscode channel (whether 'insiders' or 'stable').
*/
Expand Down
7 changes: 6 additions & 1 deletion src/client/interpreter/activation/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ export class EnvironmentActivationService
this,
this.disposables,
);
this.applicationEnvironment.onDidChangeShell(
() => this.applyCollectionForSelectedShell(),
this,
this.disposables,
);

this.initializeCollection(undefined).ignoreErrors();
}
Expand Down Expand Up @@ -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 ?? '',
Expand Down
16 changes: 16 additions & 0 deletions types/vscode.proposed.envShellEvent.d.ts
Original file line number Diff line number Diff line change
@@ -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<string>;
}
}
18 changes: 0 additions & 18 deletions types/vscode.proposed.testObserver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,6 @@ declare module 'vscode' {
readonly removed: ReadonlyArray<TestItem>;
}

/**
* 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}.
Expand Down

0 comments on commit caadaea

Please sign in to comment.