@@ -25,6 +25,7 @@ import { withNullAsUndefined } from 'vs/base/common/types';
25
25
import { Promises } from 'vs/base/common/async' ;
26
26
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn' ;
27
27
import { ViewColumn } from 'vs/workbench/api/common/extHostTypeConverters' ;
28
+ import { isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions' ;
28
29
29
30
export interface IExtHostTerminalService extends ExtHostTerminalServiceShape , IDisposable {
30
31
@@ -826,7 +827,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
826
827
public getEnvironmentVariableCollection ( extension : IExtensionDescription ) : IEnvironmentVariableCollection {
827
828
let collection = this . _environmentVariableCollections . get ( extension . identifier . value ) ;
828
829
if ( ! collection ) {
829
- collection = new EnvironmentVariableCollection ( ) ;
830
+ collection = new EnvironmentVariableCollection ( extension ) ;
830
831
this . _setEnvironmentVariableCollection ( extension . identifier . value , collection ) ;
831
832
}
832
833
return collection . getScopedEnvironmentVariableCollection ( undefined ) ;
@@ -841,7 +842,7 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
841
842
public $initEnvironmentVariableCollections ( collections : [ string , ISerializableEnvironmentVariableCollection ] [ ] ) : void {
842
843
collections . forEach ( entry => {
843
844
const extensionIdentifier = entry [ 0 ] ;
844
- const collection = new EnvironmentVariableCollection ( entry [ 1 ] ) ;
845
+ const collection = new EnvironmentVariableCollection ( undefined , entry [ 1 ] ) ;
845
846
this . _setEnvironmentVariableCollection ( extensionIdentifier , collection ) ;
846
847
} ) ;
847
848
}
@@ -883,6 +884,11 @@ class EnvironmentVariableCollection {
883
884
get onDidChangeCollection ( ) : Event < void > { return this . _onDidChangeCollection && this . _onDidChangeCollection . event ; }
884
885
885
886
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 ,
886
892
serialized ?: ISerializableEnvironmentVariableCollection
887
893
) {
888
894
this . map = new Map ( serialized ) ;
@@ -900,14 +906,23 @@ class EnvironmentVariableCollection {
900
906
}
901
907
902
908
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
+ }
903
912
this . _setIfDiffers ( variable , { value, type : EnvironmentVariableMutatorType . Replace , options : options ?? { } , scope } ) ;
904
913
}
905
914
906
915
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
+ }
907
919
this . _setIfDiffers ( variable , { value, type : EnvironmentVariableMutatorType . Append , options : options ?? { } , scope } ) ;
908
920
}
909
921
910
922
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
+ }
911
926
this . _setIfDiffers ( variable , { value, type : EnvironmentVariableMutatorType . Prepend , options : options ?? { } , scope } ) ;
912
927
}
913
928
0 commit comments