Skip to content

Commit cd5fe46

Browse files
committed
Add proposed check to options
1 parent 2830bd2 commit cd5fe46

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/vs/workbench/api/common/extHostTerminalService.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { withNullAsUndefined } from 'vs/base/common/types';
2525
import { Promises } from 'vs/base/common/async';
2626
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
2727
import { ViewColumn } from 'vs/workbench/api/common/extHostTypeConverters';
28+
import { isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
2829

2930
export interface IExtHostTerminalService extends ExtHostTerminalServiceShape, IDisposable {
3031

@@ -826,7 +827,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
826827
public getEnvironmentVariableCollection(extension: IExtensionDescription): IEnvironmentVariableCollection {
827828
let collection = this._environmentVariableCollections.get(extension.identifier.value);
828829
if (!collection) {
829-
collection = new EnvironmentVariableCollection();
830+
collection = new EnvironmentVariableCollection(extension);
830831
this._setEnvironmentVariableCollection(extension.identifier.value, collection);
831832
}
832833
return collection.getScopedEnvironmentVariableCollection(undefined);
@@ -841,7 +842,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
841842
public $initEnvironmentVariableCollections(collections: [string, ISerializableEnvironmentVariableCollection][]): void {
842843
collections.forEach(entry => {
843844
const extensionIdentifier = entry[0];
844-
const collection = new EnvironmentVariableCollection(entry[1]);
845+
const collection = new EnvironmentVariableCollection(undefined, entry[1]);
845846
this._setEnvironmentVariableCollection(extensionIdentifier, collection);
846847
});
847848
}
@@ -883,6 +884,11 @@ class EnvironmentVariableCollection {
883884
get onDidChangeCollection(): Event<void> { return this._onDidChangeCollection && this._onDidChangeCollection.event; }
884885

885886
constructor(
887+
// HACK: Only check proposed options if extension is set (when the collection is not
888+
// restored by serialization). This saves us from getting the extension details and
889+
// shouldn't ever happen since you can only set them initially via the proposed check.
890+
// TODO: This should be removed when the env var extension API(s) are stabilized
891+
private readonly _extension: IExtensionDescription | undefined,
886892
serialized?: ISerializableEnvironmentVariableCollection
887893
) {
888894
this.map = new Map(serialized);
@@ -900,14 +906,23 @@ class EnvironmentVariableCollection {
900906
}
901907

902908
replace(variable: string, value: string, options: vscode.EnvironmentVariableMutatorOptions | undefined, scope: vscode.EnvironmentVariableScope | undefined): void {
909+
if (this._extension && options) {
910+
isProposedApiEnabled(this._extension, 'envCollectionOptions');
911+
}
903912
this._setIfDiffers(variable, { value, type: EnvironmentVariableMutatorType.Replace, options: options ?? {}, scope });
904913
}
905914

906915
append(variable: string, value: string, options: vscode.EnvironmentVariableMutatorOptions | undefined, scope: vscode.EnvironmentVariableScope | undefined): void {
916+
if (this._extension && options) {
917+
isProposedApiEnabled(this._extension, 'envCollectionOptions');
918+
}
907919
this._setIfDiffers(variable, { value, type: EnvironmentVariableMutatorType.Append, options: options ?? {}, scope });
908920
}
909921

910922
prepend(variable: string, value: string, options: vscode.EnvironmentVariableMutatorOptions | undefined, scope: vscode.EnvironmentVariableScope | undefined): void {
923+
if (this._extension && options) {
924+
isProposedApiEnabled(this._extension, 'envCollectionOptions');
925+
}
911926
this._setIfDiffers(variable, { value, type: EnvironmentVariableMutatorType.Prepend, options: options ?? {}, scope });
912927
}
913928

0 commit comments

Comments
 (0)