diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index f1a029ec55f2fe7b5f4eb5a405b7518c649b27e5..d34babb11c3e485691feef1381cf6dd1d25e89a3 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -54,6 +54,7 @@ import { revive } from 'vs/base/common/marshalling'; import { INotebookMimeTypeSelector, IOutput, INotebookDisplayOrder, NotebookCellMetadata, NotebookDocumentMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon'; import { CallHierarchyItem } from 'vs/workbench/contrib/callHierarchy/common/callHierarchy'; import { Dto } from 'vs/base/common/types'; +import { EnvironmentVariableMutatorType } from 'vs/workbench/contrib/terminal/common/environmentVariable'; export interface IEnvironment { isExtensionDevelopmentDebug: boolean; @@ -426,12 +427,6 @@ export interface TerminalLaunchConfig { isExtensionTerminal?: boolean; } -export enum EnvironmentVariableMutatorType { - Replace = 1, - Append = 2, - Prepend = 3 -} - export interface IEnvironmentVariableCollectionDto { extensionIdentifier: string; variables: string[]; diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index b332a4e5cde91f315b49405d01b54d430e1c6aa9..3f150634ab7149fdec3f44b6ab840e411bf8c539 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -674,6 +674,7 @@ export class WorkerExtHostTerminalService extends BaseExtHostTerminalService { } public getEnvironmentVariableCollection(extension: IExtensionDescription, persistent?: boolean): vscode.EnvironmentVariableCollection { + // This is not implemented so worker ext host extensions cannot influence terminal envs throw new Error('Not implemented'); } } diff --git a/src/vs/workbench/api/node/extHostTerminalService.ts b/src/vs/workbench/api/node/extHostTerminalService.ts index ae78dfb7b78c23e4d7cbfd8879a3e0b5955b3003..3d64ebc8f5ae84918fccce66d709fafa00de5675 100644 --- a/src/vs/workbench/api/node/extHostTerminalService.ts +++ b/src/vs/workbench/api/node/extHostTerminalService.ts @@ -9,7 +9,7 @@ import * as os from 'os'; import { URI, UriComponents } from 'vs/base/common/uri'; import * as platform from 'vs/base/common/platform'; import * as terminalEnvironment from 'vs/workbench/contrib/terminal/common/terminalEnvironment'; -import { IShellLaunchConfigDto, IShellDefinitionDto, IShellAndArgsDto } from 'vs/workbench/api/common/extHost.protocol'; +import { IShellLaunchConfigDto, IShellDefinitionDto, IShellAndArgsDto, IEnvironmentVariableCollectionDto } from 'vs/workbench/api/common/extHost.protocol'; import { ExtHostConfiguration, ExtHostConfigProvider, IExtHostConfiguration } from 'vs/workbench/api/common/extHostConfiguration'; import { ILogService } from 'vs/platform/log/common/log'; import { IShellLaunchConfig, ITerminalEnvironment } from 'vs/workbench/contrib/terminal/common/terminal'; @@ -287,13 +287,35 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService { } else { collection = new EnvironmentVariableCollection(); } - collection.onDidChangeCollection(() => this._updateEnvironmentVariableCollection()); + collection.onDidChangeCollection(() => this._updateEnvironmentVariableCollections()); this._environmentVariableCollection.set(extension.identifier.value, collection); return collection; } @debounce(1000) - private _updateEnvironmentVariableCollection() { + private _updateEnvironmentVariableCollections(): void { + const dtos: IEnvironmentVariableCollectionDto[] = []; + this._environmentVariableCollection.forEach((collection, extensionIdenfitier) => { + dtos.push(this._serializeEnvironmentVariableCollection(extensionIdenfitier, collection)); + }); + // TODO: Send updates back to renderer } + + private _serializeEnvironmentVariableCollection(extensionIdentifier: string, collection: vscode.EnvironmentVariableCollection): IEnvironmentVariableCollectionDto { + const variables: string[] = []; + const values: string[] = []; + const types: EnvironmentVariableMutatorType[] = []; + collection.forEach((variable, mutator) => { + variables.push(variable); + values.push(mutator.value); + types.push(mutator.type); + }); + return { + extensionIdentifier, + variables, + values, + types + }; + } } diff --git a/src/vs/workbench/contrib/terminal/common/environmentVariable.ts b/src/vs/workbench/contrib/terminal/common/environmentVariable.ts index d513a3f6588c01f66a8326b760b613a2bdaf1168..4cbfcf4d43dd9a04c74d0ed5a0473f6345f061d1 100644 --- a/src/vs/workbench/contrib/terminal/common/environmentVariable.ts +++ b/src/vs/workbench/contrib/terminal/common/environmentVariable.ts @@ -7,9 +7,15 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' export const IEnvironmentVariableService = createDecorator('environmentVariableService'); +export enum EnvironmentVariableMutatorType { + Replace = 1, + Append = 2, + Prepend = 3 +} + export interface IEnvironmentVariableMutator { readonly value: string; - readonly type: 'replace' | 'append' | 'prepend'; + readonly type: EnvironmentVariableMutatorType; } export interface IEnvironmentVariableCollection {