mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Finalize proposed env workspace collection API
This commit is contained in:
parent
f40dabca07
commit
b1d5542cfd
|
@ -51,7 +51,6 @@
|
|||
"telemetry",
|
||||
"windowActivity",
|
||||
"interactiveUserActions",
|
||||
"envCollectionWorkspace",
|
||||
"envCollectionOptions"
|
||||
],
|
||||
"private": true,
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { deepStrictEqual, doesNotThrow, equal, ok, strictEqual, throws } from 'assert';
|
||||
import { commands, ConfigurationTarget, Disposable, env, EnvironmentVariableMutator, EnvironmentVariableMutatorOptions, EnvironmentVariableMutatorType, EventEmitter, ExtensionContext, extensions, ExtensionTerminalOptions, GlobalEnvironmentVariableCollection, Pseudoterminal, Terminal, TerminalDimensions, TerminalExitReason, TerminalOptions, TerminalState, UIKind, Uri, window, workspace } from 'vscode';
|
||||
import { commands, ConfigurationTarget, Disposable, env, EnvironmentVariableMutator, EnvironmentVariableMutatorOptions, EnvironmentVariableMutatorType, EventEmitter, ExtensionContext, extensions, ExtensionTerminalOptions, Pseudoterminal, Terminal, TerminalDimensions, TerminalExitReason, TerminalOptions, TerminalState, UIKind, Uri, window, workspace } from 'vscode';
|
||||
import { assertNoRpc, poll } from '../utils';
|
||||
|
||||
// Disable terminal tests:
|
||||
|
@ -912,8 +912,7 @@ import { assertNoRpc, poll } from '../utils';
|
|||
});
|
||||
|
||||
test('get and forEach should work (scope)', () => {
|
||||
// TODO: Remove cast once `envCollectionWorkspace` API is finalized.
|
||||
const collection = extensionContext.environmentVariableCollection as GlobalEnvironmentVariableCollection;
|
||||
const collection = extensionContext.environmentVariableCollection;
|
||||
disposables.push({ dispose: () => collection.clear() });
|
||||
const scope = { workspaceFolder: { uri: Uri.file('workspace1'), name: 'workspace1', index: 0 } };
|
||||
const scopedCollection = collection.getScoped(scope);
|
||||
|
|
|
@ -929,10 +929,6 @@ class UnifiedEnvironmentVariableCollection {
|
|||
}
|
||||
|
||||
getScopedEnvironmentVariableCollection(scope: vscode.EnvironmentVariableScope | undefined): IEnvironmentVariableCollection {
|
||||
if (this._extension && scope) {
|
||||
// TODO: This should be removed when the env var extension API(s) are stabilized
|
||||
checkProposedApiEnabled(this._extension, 'envCollectionWorkspace');
|
||||
}
|
||||
const scopedCollectionKey = this.getScopeKey(scope);
|
||||
let scopedCollection = this.scopedCollections.get(scopedCollectionKey);
|
||||
if (!scopedCollection) {
|
||||
|
|
|
@ -41,7 +41,6 @@ export const allApiProposals = Object.freeze({
|
|||
editSessionIdentityProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.editSessionIdentityProvider.d.ts',
|
||||
editorInsets: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.editorInsets.d.ts',
|
||||
envCollectionOptions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.envCollectionOptions.d.ts',
|
||||
envCollectionWorkspace: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.envCollectionWorkspace.d.ts',
|
||||
envShellEvent: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.envShellEvent.d.ts',
|
||||
extensionRuntime: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.extensionRuntime.d.ts',
|
||||
extensionsAny: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.extensionsAny.d.ts',
|
||||
|
|
31
src/vscode-dts/vscode.d.ts
vendored
31
src/vscode-dts/vscode.d.ts
vendored
|
@ -7185,10 +7185,10 @@ declare module 'vscode' {
|
|||
readonly extensionPath: string;
|
||||
|
||||
/**
|
||||
* Gets the extension's environment variable collection for this workspace, enabling changes
|
||||
* to be applied to terminal environment variables.
|
||||
* Gets the extension's global environment variable collection for this workspace, enabling changes to be
|
||||
* applied to terminal environment variables.
|
||||
*/
|
||||
readonly environmentVariableCollection: EnvironmentVariableCollection;
|
||||
readonly environmentVariableCollection: GlobalEnvironmentVariableCollection;
|
||||
|
||||
/**
|
||||
* Get the absolute path of a resource contained in the extension.
|
||||
|
@ -11429,6 +11429,31 @@ declare module 'vscode' {
|
|||
clear(): void;
|
||||
}
|
||||
|
||||
export interface GlobalEnvironmentVariableCollection extends EnvironmentVariableCollection {
|
||||
/**
|
||||
* Gets scope-specific environment variable collection for the extension. This enables alterations to
|
||||
* terminal environment variables solely within the designated scope, and is applied in addition to (and
|
||||
* after) the global collection.
|
||||
*
|
||||
* Each object obtained through this method is isolated and does not impact objects for other scopes,
|
||||
* including the global collection.
|
||||
*
|
||||
* @param scope The scope to which the environment variable collection applies to.
|
||||
*
|
||||
* If a scope parameter is omitted, collection applicable to all relevant scopes for that parameter is
|
||||
* returned. For instance, if the 'workspaceFolder' parameter is not specified, the collection that applies
|
||||
* across all workspace folders will be returned.
|
||||
*/
|
||||
getScoped(scope: EnvironmentVariableScope): EnvironmentVariableCollection;
|
||||
}
|
||||
|
||||
export type EnvironmentVariableScope = {
|
||||
/**
|
||||
* Any specific workspace folder to get collection for. If unspecified, collection applicable to all workspace folders is returned.
|
||||
*/
|
||||
workspaceFolder?: WorkspaceFolder;
|
||||
};
|
||||
|
||||
/**
|
||||
* A location in the editor at which progress information can be shown. It depends on the
|
||||
* location how progress is visually represented.
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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' {
|
||||
|
||||
// https://github.com/microsoft/vscode/issues/171173
|
||||
|
||||
// export interface ExtensionContext {
|
||||
// /**
|
||||
// * Gets the extension's global environment variable collection for this workspace, enabling changes to be
|
||||
// * applied to terminal environment variables.
|
||||
// */
|
||||
// readonly environmentVariableCollection: GlobalEnvironmentVariableCollection;
|
||||
// }
|
||||
|
||||
export interface GlobalEnvironmentVariableCollection extends EnvironmentVariableCollection {
|
||||
/**
|
||||
* Gets scope-specific environment variable collection for the extension. This enables alterations to
|
||||
* terminal environment variables solely within the designated scope, and is applied in addition to (and
|
||||
* after) the global collection.
|
||||
*
|
||||
* Each object obtained through this method is isolated and does not impact objects for other scopes,
|
||||
* including the global collection.
|
||||
*
|
||||
* @param scope The scope to which the environment variable collection applies to.
|
||||
*
|
||||
* If a scope parameter is omitted, collection applicable to all relevant scopes for that parameter is
|
||||
* returned. For instance, if the 'workspaceFolder' parameter is not specified, the collection that applies
|
||||
* across all workspace folders will be returned.
|
||||
*/
|
||||
getScoped(scope: EnvironmentVariableScope): EnvironmentVariableCollection;
|
||||
}
|
||||
|
||||
export type EnvironmentVariableScope = {
|
||||
/**
|
||||
* Any specific workspace folder to get collection for. If unspecified, collection applicable to all workspace folders is returned.
|
||||
*/
|
||||
workspaceFolder?: WorkspaceFolder;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue