提交 b2a9d4dd 编写于 作者: D Daniel Imms

Serialize collections on ext host

上级 b41b85d2
......@@ -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[];
......
......@@ -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');
}
}
......@@ -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
};
}
}
......@@ -7,9 +7,15 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
export const IEnvironmentVariableService = createDecorator<IEnvironmentVariableService>('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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册