mirror of
https://github.com/microsoft/vscode.git
synced 2026-02-15 07:28:05 +00:00
Get environment variable collection status updating after reconnect
Part of #142826
This commit is contained in:
@@ -10,6 +10,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
|
||||
import { ITerminalCapabilityStore } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
import { IGetTerminalLayoutInfoArgs, IProcessDetails, IPtyHostProcessReplayEvent, ISerializedCommandDetectionCapability, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
|
||||
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
|
||||
import { IEnvironmentVariableCollection, ISerializableEnvironmentVariableCollections } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
|
||||
export const enum TerminalSettingPrefix {
|
||||
Shell = 'terminal.integrated.shell.',
|
||||
@@ -159,6 +160,7 @@ export interface IPtyHostAttachTarget {
|
||||
isOrphan: boolean;
|
||||
icon: TerminalIcon | undefined;
|
||||
fixedDimensions: IFixedTerminalDimensions | undefined;
|
||||
environmentVariableCollections: ISerializableEnvironmentVariableCollections | undefined;
|
||||
}
|
||||
|
||||
export enum TitleEventSource {
|
||||
@@ -522,6 +524,9 @@ export interface IShellLaunchConfig {
|
||||
* Opt-out of the default terminal persistence on restart and reload
|
||||
*/
|
||||
isTransient?: boolean;
|
||||
|
||||
// TODO: doc
|
||||
environmentVariableCollections?: ReadonlyMap<string, IEnvironmentVariableCollection>;
|
||||
}
|
||||
|
||||
export interface ICreateContributedTerminalProfileOptions {
|
||||
@@ -561,6 +566,7 @@ export interface ITerminalProcessOptions {
|
||||
enabled: boolean;
|
||||
};
|
||||
windowsEnableConpty: boolean;
|
||||
environmentVariableCollections: ISerializableEnvironmentVariableCollections | undefined;
|
||||
}
|
||||
|
||||
export interface ITerminalEnvironment {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import { UriComponents } from 'vs/base/common/uri';
|
||||
import { ISerializableEnvironmentVariableCollection } from 'vs/platform/terminal/common/environmentVariable';
|
||||
import { IFixedTerminalDimensions, IRawTerminalTabLayoutInfo, ITerminalEnvironment, ITerminalTabLayoutInfoById, TerminalIcon, TitleEventSource } from 'vs/platform/terminal/common/terminal';
|
||||
import { ISerializableEnvironmentVariableCollections } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
|
||||
export interface ISingleTerminalConfiguration<T> {
|
||||
userValue: T | undefined;
|
||||
@@ -59,6 +60,7 @@ export interface IProcessDetails {
|
||||
icon: TerminalIcon | undefined;
|
||||
color: string | undefined;
|
||||
fixedDimensions: IFixedTerminalDimensions | undefined;
|
||||
environmentVariableCollections: ISerializableEnvironmentVariableCollections | undefined;
|
||||
}
|
||||
|
||||
export type ITerminalTabLayoutInfoDto = IRawTerminalTabLayoutInfo<IProcessDetails>;
|
||||
|
||||
@@ -128,6 +128,7 @@ export class PtyService extends Disposable implements IPtyService {
|
||||
|
||||
async reviveTerminalProcesses(state: ISerializedTerminalState[], dateTimeFormatLocate: string) {
|
||||
for (const terminal of state) {
|
||||
this._logService.info('revive', terminal.processLaunchConfig);
|
||||
const restoreMessage = localize({
|
||||
key: 'terminal-session-restore',
|
||||
comment: ['date the snapshot was taken', 'time the snapshot was taken']
|
||||
@@ -176,6 +177,7 @@ export class PtyService extends Disposable implements IPtyService {
|
||||
workspaceName: string,
|
||||
isReviving?: boolean
|
||||
): Promise<number> {
|
||||
this._logService.info('create process options', options);
|
||||
if (shellLaunchConfig.attachPersistentProcess) {
|
||||
throw new Error('Attempt to create a process when attach object was provided');
|
||||
}
|
||||
@@ -383,6 +385,7 @@ export class PtyService extends Disposable implements IPtyService {
|
||||
// If the process was just revived, don't do the orphan check as it will
|
||||
// take some time
|
||||
const [cwd, isOrphan] = await Promise.all([persistentProcess.getCwd(), wasRevived ? true : persistentProcess.isOrphaned()]);
|
||||
this._logService.info('_buildProcessDetails', 'collections', persistentProcess.processLaunchOptions.options.environmentVariableCollections);
|
||||
return {
|
||||
id,
|
||||
title: persistentProcess.title,
|
||||
@@ -394,7 +397,8 @@ export class PtyService extends Disposable implements IPtyService {
|
||||
isOrphan,
|
||||
icon: persistentProcess.icon,
|
||||
color: persistentProcess.color,
|
||||
fixedDimensions: persistentProcess.fixedDimensions
|
||||
fixedDimensions: persistentProcess.fixedDimensions,
|
||||
environmentVariableCollections: persistentProcess.processLaunchOptions.options.environmentVariableCollections
|
||||
};
|
||||
}
|
||||
|
||||
@@ -571,6 +575,7 @@ export class PersistentTerminalProcess extends Disposable {
|
||||
}
|
||||
|
||||
async start(): Promise<ITerminalLaunchError | undefined> {
|
||||
// TODO: ext environment variable collection needs to make it back to the renderer
|
||||
this._logService.trace('persistentTerminalProcess#start', this._persistentProcessId, this._isStarted);
|
||||
if (!this._isStarted) {
|
||||
const result = await this._terminalProcess.start();
|
||||
|
||||
@@ -18,6 +18,7 @@ import { IKeyMods } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { ITerminalCapabilityStore, ITerminalCommand } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
|
||||
import { IEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
|
||||
export const ITerminalService = createDecorator<ITerminalService>('terminalService');
|
||||
export const ITerminalEditorService = createDecorator<ITerminalEditorService>('terminalEditorService');
|
||||
@@ -281,6 +282,9 @@ export interface ICreateTerminalOptions {
|
||||
* The terminal's location (editor or panel), it's terminal parent (split to the right), or editor group
|
||||
*/
|
||||
location?: ITerminalLocationOptions;
|
||||
|
||||
// TODO: doc
|
||||
environmentVariableCollection?: Map<string, IEnvironmentVariableCollection>;
|
||||
}
|
||||
|
||||
export interface TerminalEditorLocation {
|
||||
|
||||
@@ -1447,7 +1447,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
||||
}
|
||||
|
||||
protected _createProcessManager(): TerminalProcessManager {
|
||||
const processManager = this._instantiationService.createInstance(TerminalProcessManager, this._instanceId, this._configHelper, this.shellLaunchConfig?.cwd);
|
||||
const processManager = this._instantiationService.createInstance(TerminalProcessManager, this._instanceId, this._configHelper, this.shellLaunchConfig?.cwd, this.shellLaunchConfig?.environmentVariableCollections);
|
||||
this.capabilities.add(processManager.capabilities);
|
||||
processManager.onProcessReady(async (e) => {
|
||||
this._onProcessIdReady.fire(this);
|
||||
@@ -2156,7 +2156,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
||||
if (
|
||||
!info ||
|
||||
this._configHelper.config.environmentChangesIndicator === 'off' ||
|
||||
this._configHelper.config.environmentChangesIndicator === 'warnonly' && !info.requiresAction
|
||||
this._configHelper.config.environmentChangesIndicator === 'warnonly' && !info.requiresAction ||
|
||||
this._configHelper.config.environmentChangesIndicator === 'on' && !info.requiresAction
|
||||
) {
|
||||
this.statusList.remove(TerminalStatus.RelaunchNeeded);
|
||||
this._environmentInfo?.disposable.dispose();
|
||||
@@ -2508,6 +2509,7 @@ export class TerminalLabelComputer extends Disposable {
|
||||
|
||||
private readonly _onDidChangeLabel = this._register(new Emitter<{ title: string; description: string }>());
|
||||
readonly onDidChangeLabel = this._onDidChangeLabel.event;
|
||||
|
||||
constructor(
|
||||
private readonly _configHelper: TerminalConfigHelper,
|
||||
private readonly _instance: Pick<ITerminalInstance, 'shellLaunchConfig' | 'cwd' | 'fixedCols' | 'fixedRows' | 'initialCwd' | 'processName' | 'sequence' | 'userHome' | 'workspaceFolder' | 'staticTitle' | 'capabilities' | 'title' | 'description'>,
|
||||
|
||||
@@ -3,37 +3,39 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as terminalEnvironment from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
|
||||
import { ProcessState, ITerminalProcessManager, ITerminalConfigHelper, IBeforeProcessDataEvent, ITerminalProfileResolverService, ITerminalBackend } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
import { Disposable, dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { EnvironmentVariableInfoChangesActive, EnvironmentVariableInfoStale } from 'vs/workbench/contrib/terminal/browser/environmentVariableInfo';
|
||||
import { IPathService } from 'vs/workbench/services/path/common/pathService';
|
||||
import { IEnvironmentVariableInfo, IEnvironmentVariableService, IMergedEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
import { IProcessDataEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalEnvironment, ITerminalLaunchError, FlowControlConstants, ITerminalDimensions, IProcessReadyEvent, IProcessProperty, ProcessPropertyType, IProcessPropertyMap, ITerminalProcessOptions, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
|
||||
import { TerminalRecorder } from 'vs/platform/terminal/common/terminalRecorder';
|
||||
import { localize } from 'vs/nls';
|
||||
import { formatMessageForTerminal } from 'vs/workbench/contrib/terminal/common/terminalStrings';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IProcessEnvironment, isMacintosh, isWindows, OperatingSystem, OS } from 'vs/base/common/platform';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { TerminalCapabilityStore } from 'vs/platform/terminal/common/capabilities/terminalCapabilityStore';
|
||||
import { NaiveCwdDetectionCapability } from 'vs/platform/terminal/common/capabilities/naiveCwdDetectionCapability';
|
||||
import { TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ISerializedCommandDetectionCapability } from 'vs/platform/terminal/common/terminalProcess';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
|
||||
import { NaiveCwdDetectionCapability } from 'vs/platform/terminal/common/capabilities/naiveCwdDetectionCapability';
|
||||
import { TerminalCapabilityStore } from 'vs/platform/terminal/common/capabilities/terminalCapabilityStore';
|
||||
import { FlowControlConstants, IProcessDataEvent, IProcessProperty, IProcessPropertyMap, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensions, ITerminalEnvironment, ITerminalLaunchError, ITerminalProcessOptions, ProcessPropertyType, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
|
||||
import { ISerializedCommandDetectionCapability } from 'vs/platform/terminal/common/terminalProcess';
|
||||
import { TerminalRecorder } from 'vs/platform/terminal/common/terminalRecorder';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { EnvironmentVariableInfoChangesActive, EnvironmentVariableInfoStale } from 'vs/workbench/contrib/terminal/browser/environmentVariableInfo';
|
||||
import { ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { IEnvironmentVariableCollection, IEnvironmentVariableInfo, IEnvironmentVariableService, IMergedEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
import { MergedEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariableCollection';
|
||||
import { serializeEnvironmentVariableCollections } from 'vs/workbench/contrib/terminal/common/environmentVariableShared';
|
||||
import { IBeforeProcessDataEvent, ITerminalBackend, ITerminalConfigHelper, ITerminalProcessManager, ITerminalProfileResolverService, ProcessState } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
import * as terminalEnvironment from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
|
||||
import { formatMessageForTerminal } from 'vs/workbench/contrib/terminal/common/terminalStrings';
|
||||
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IHistoryService } from 'vs/workbench/services/history/common/history';
|
||||
import { IPathService } from 'vs/workbench/services/path/common/pathService';
|
||||
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
|
||||
/** The amount of time to consider terminal errors to be related to the launch */
|
||||
const LAUNCHING_DURATION = 500;
|
||||
@@ -119,6 +121,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
||||
private readonly _instanceId: number,
|
||||
private readonly _configHelper: ITerminalConfigHelper,
|
||||
cwd: string | URI | undefined,
|
||||
extEnvironmentVariableCollection: ReadonlyMap<string, IEnvironmentVariableCollection> | undefined,
|
||||
@IHistoryService private readonly _historyService: IHistoryService,
|
||||
@IInstantiationService private readonly _instantiationService: IInstantiationService,
|
||||
@ILogService private readonly _logService: ILogService,
|
||||
@@ -158,6 +161,19 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
||||
} else {
|
||||
this.remoteAuthority = this._workbenchEnvironmentService.remoteAuthority;
|
||||
}
|
||||
|
||||
console.log('ctor env var collections', extEnvironmentVariableCollection);
|
||||
if (extEnvironmentVariableCollection) {
|
||||
this._extEnvironmentVariableCollection = new MergedEnvironmentVariableCollection(extEnvironmentVariableCollection);
|
||||
this._register(this._environmentVariableService.onDidChangeCollections(newCollection => this._onEnvironmentVariableCollectionChange(newCollection)));
|
||||
this.environmentVariableInfo = new EnvironmentVariableInfoChangesActive(this._extEnvironmentVariableCollection);
|
||||
this._onEnvironmentVariableInfoChange.fire(this.environmentVariableInfo);
|
||||
}
|
||||
|
||||
// this.onEnvironmentVariableInfoChanged(e => {
|
||||
// // TODO: Fix types, see any
|
||||
// this._process?.updateProperty(ProcessPropertyType.EnvironmentVariableCollection, this._extEnvironmentVariableCollection?.map ? serializeEnvironmentVariableCollection(this._extEnvironmentVariableCollection.map as any) : undefined)
|
||||
// });
|
||||
}
|
||||
|
||||
override dispose(immediate: boolean = false): void {
|
||||
@@ -253,7 +269,8 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
||||
shellIntegration: {
|
||||
enabled: this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled)
|
||||
},
|
||||
windowsEnableConpty: this._configHelper.config.windowsEnableConpty && !isScreenReaderModeEnabled
|
||||
windowsEnableConpty: this._configHelper.config.windowsEnableConpty && !isScreenReaderModeEnabled,
|
||||
environmentVariableCollections: this._extEnvironmentVariableCollection?.collections ? serializeEnvironmentVariableCollections(this._extEnvironmentVariableCollection.collections) : undefined
|
||||
};
|
||||
try {
|
||||
newProcess = await backend.createProcess(
|
||||
@@ -394,7 +411,10 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
||||
|
||||
const env = await terminalEnvironment.createTerminalEnvironment(shellLaunchConfig, envFromConfigValue, variableResolver, this._productService.version, this._configHelper.config.detectLocale, baseEnv);
|
||||
if (!this._isDisposed && !shellLaunchConfig.strictEnv && !shellLaunchConfig.hideFromUser) {
|
||||
console.log('_resolveEnvironment collections', this._shellLaunchConfig?.environmentVariableCollections);
|
||||
this._extEnvironmentVariableCollection = this._environmentVariableService.mergedCollection;
|
||||
// TODO: Check if it's already conflicting
|
||||
|
||||
this._register(this._environmentVariableService.onDidChangeCollections(newCollection => this._onEnvironmentVariableCollectionChange(newCollection)));
|
||||
// For remote terminals, this is a copy of the mergedEnvironmentCollection created on
|
||||
// the remote side. Since the environment collection is synced between the remote and
|
||||
@@ -442,7 +462,8 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
||||
shellIntegration: {
|
||||
enabled: this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled)
|
||||
},
|
||||
windowsEnableConpty: this._configHelper.config.windowsEnableConpty && !isScreenReaderModeEnabled
|
||||
windowsEnableConpty: this._configHelper.config.windowsEnableConpty && !isScreenReaderModeEnabled,
|
||||
environmentVariableCollections: this._extEnvironmentVariableCollection ? serializeEnvironmentVariableCollections(this._extEnvironmentVariableCollection.collections) : undefined
|
||||
};
|
||||
const shouldPersist = this._configHelper.config.enablePersistentSessions && !shellLaunchConfig.isFeatureTerminal;
|
||||
return await backend.createProcess(shellLaunchConfig, initialCwd, cols, rows, this._configHelper.config.unicodeVersion, env, options, shouldPersist);
|
||||
@@ -620,6 +641,11 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce
|
||||
private _onEnvironmentVariableCollectionChange(newCollection: IMergedEnvironmentVariableCollection): void {
|
||||
const diff = this._extEnvironmentVariableCollection!.diff(newCollection);
|
||||
if (diff === undefined) {
|
||||
// If there are no longer differences, remove the stale info indicator
|
||||
if (this.environmentVariableInfo instanceof EnvironmentVariableInfoStale) {
|
||||
this.environmentVariableInfo = new EnvironmentVariableInfoChangesActive(this._extEnvironmentVariableCollection!);
|
||||
this._onEnvironmentVariableInfoChange.fire(this.environmentVariableInfo);
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.environmentVariableInfo = this._instantiationService.createInstance(EnvironmentVariableInfoStale, diff, this._instanceId);
|
||||
|
||||
@@ -45,6 +45,8 @@ import { TerminalEditorInput } from 'vs/workbench/contrib/terminal/browser/termi
|
||||
import { getCwdForSplit } from 'vs/workbench/contrib/terminal/browser/terminalActions';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { deserializeEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariableShared';
|
||||
import { IEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
|
||||
export class TerminalService implements ITerminalService {
|
||||
declare _serviceBrand: undefined;
|
||||
@@ -412,6 +414,7 @@ export class TerminalService implements ITerminalService {
|
||||
}
|
||||
|
||||
private async _recreateTerminalGroups(layoutInfo?: ITerminalsLayoutInfo): Promise<number> {
|
||||
console.log('recreate terminal groups', layoutInfo);
|
||||
let reconnectCounter = 0;
|
||||
let activeGroup: ITerminalGroup | undefined;
|
||||
if (layoutInfo) {
|
||||
@@ -422,10 +425,13 @@ export class TerminalService implements ITerminalService {
|
||||
let terminalInstance: ITerminalInstance | undefined;
|
||||
let group: ITerminalGroup | undefined;
|
||||
for (const terminalLayout of terminalLayouts) {
|
||||
const deserializedCollections = terminalLayout.terminal?.environmentVariableCollections?.map(e => {
|
||||
return [e[0], { map: deserializeEnvironmentVariableCollection(e[1]) }];
|
||||
}) as [string, IEnvironmentVariableCollection][];
|
||||
if (!terminalInstance) {
|
||||
// create group and terminal
|
||||
terminalInstance = await this.createTerminal({
|
||||
config: { attachPersistentProcess: terminalLayout.terminal! },
|
||||
config: { attachPersistentProcess: terminalLayout.terminal!, environmentVariableCollections: new Map(deserializedCollections) },
|
||||
location: TerminalLocation.Panel
|
||||
});
|
||||
group = this._terminalGroupService.getGroupForInstance(terminalInstance);
|
||||
@@ -434,7 +440,10 @@ export class TerminalService implements ITerminalService {
|
||||
}
|
||||
} else {
|
||||
// add split terminals to this group
|
||||
terminalInstance = await this.createTerminal({ config: { attachPersistentProcess: terminalLayout.terminal! }, location: { parentTerminal: terminalInstance } });
|
||||
terminalInstance = await this.createTerminal({
|
||||
config: { attachPersistentProcess: terminalLayout.terminal!, environmentVariableCollections: new Map(deserializedCollections) },
|
||||
location: { parentTerminal: terminalInstance }
|
||||
});
|
||||
}
|
||||
}
|
||||
const activeInstance = this.instances.find(t => {
|
||||
|
||||
@@ -45,6 +45,7 @@ export interface IMergedEnvironmentVariableCollectionDiff {
|
||||
* together.
|
||||
*/
|
||||
export interface IMergedEnvironmentVariableCollection {
|
||||
readonly collections: ReadonlyMap<string, IEnvironmentVariableCollection>;
|
||||
readonly map: ReadonlyMap<string, IExtensionOwnedEnvironmentVariableMutator[]>;
|
||||
|
||||
/**
|
||||
@@ -61,6 +62,9 @@ export interface IMergedEnvironmentVariableCollection {
|
||||
diff(other: IMergedEnvironmentVariableCollection): IMergedEnvironmentVariableCollectionDiff | undefined;
|
||||
}
|
||||
|
||||
/** [ext, mutators] */
|
||||
// export type ISerializableMergedEnvironmentVariableCollection = [string, IExtensionOwnedEnvironmentVariableMutator[]][];
|
||||
|
||||
/**
|
||||
* Tracks and persists environment variable collections as defined by extensions.
|
||||
*/
|
||||
@@ -99,6 +103,9 @@ export interface IEnvironmentVariableService {
|
||||
/** [variable, mutator] */
|
||||
export type ISerializableEnvironmentVariableCollection = [string, IEnvironmentVariableMutator][];
|
||||
|
||||
/** [extension, collection] */
|
||||
export type ISerializableEnvironmentVariableCollections = [string, ISerializableEnvironmentVariableCollection][];
|
||||
|
||||
export interface IEnvironmentVariableInfo {
|
||||
readonly requiresAction: boolean;
|
||||
getInfo(): string;
|
||||
|
||||
@@ -10,7 +10,9 @@ import { VariableResolver } from 'vs/workbench/contrib/terminal/common/terminalE
|
||||
export class MergedEnvironmentVariableCollection implements IMergedEnvironmentVariableCollection {
|
||||
readonly map: Map<string, IExtensionOwnedEnvironmentVariableMutator[]> = new Map();
|
||||
|
||||
constructor(collections: Map<string, IEnvironmentVariableCollection>) {
|
||||
constructor(
|
||||
readonly collections: ReadonlyMap<string, IEnvironmentVariableCollection>
|
||||
) {
|
||||
collections.forEach((collection, extensionIdentifier) => {
|
||||
const it = collection.map.entries();
|
||||
let next = it.next();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IEnvironmentVariableMutator, ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
import { IEnvironmentVariableCollection, IEnvironmentVariableMutator, ISerializableEnvironmentVariableCollection, ISerializableEnvironmentVariableCollections } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
|
||||
// This file is shared between the renderer and extension host
|
||||
|
||||
@@ -16,3 +16,43 @@ export function deserializeEnvironmentVariableCollection(
|
||||
): Map<string, IEnvironmentVariableMutator> {
|
||||
return new Map<string, IEnvironmentVariableMutator>(serializedCollection);
|
||||
}
|
||||
|
||||
export function serializeEnvironmentVariableCollections(collections: ReadonlyMap<string, IEnvironmentVariableCollection>): ISerializableEnvironmentVariableCollections {
|
||||
return Array.from(collections.entries()).map(e => {
|
||||
return [e[0], serializeEnvironmentVariableCollection(e[1].map)];
|
||||
});
|
||||
}
|
||||
|
||||
export function deserializeEnvironmentVariableCollections(
|
||||
serializedCollection: ISerializableEnvironmentVariableCollections
|
||||
): Map<string, IEnvironmentVariableCollection> {
|
||||
return new Map<string, IEnvironmentVariableCollection>(serializedCollection.map(e => {
|
||||
return [e[0], { map: deserializeEnvironmentVariableCollection(e[1]) }];
|
||||
}));
|
||||
}
|
||||
|
||||
// export function serializeMergedEnvironmentVariableCollection(collection: ReadonlyMap<string, IExtensionOwnedEnvironmentVariableMutator[]> | undefined): ISerializableMergedEnvironmentVariableCollection | undefined {
|
||||
// if (!collection) {
|
||||
// return undefined;
|
||||
// }
|
||||
// return [...collection.entries()];
|
||||
// }
|
||||
|
||||
// export function deserializeMergedEnvironmentVariableCollection(
|
||||
// serializedCollection: ISerializableMergedEnvironmentVariableCollection | undefined
|
||||
// ): Map<string, IExtensionOwnedEnvironmentVariableMutator[]> | undefined {
|
||||
// if (!serializedCollection) {
|
||||
// return undefined;
|
||||
// }
|
||||
// // const entries: [string, IEnvironmentVariableCollection][] = [];
|
||||
// // const envVariableCollections = new Map<string, IEnvironmentVariableCollection>(entries);
|
||||
// // for (const [k, v] of envVariableCollections) {
|
||||
// // entries.push([k, { map: deserializeEnvironmentVariableCollection(v) }]);
|
||||
// // }
|
||||
// // const mergedCollection = new MergedEnvironmentVariableCollection(envVariableCollections);
|
||||
// return new Map<string, IExtensionOwnedEnvironmentVariableMutator[]>(serializedCollection);
|
||||
// }
|
||||
|
||||
// export function removeExtOwned() {
|
||||
|
||||
// }
|
||||
|
||||
@@ -104,7 +104,7 @@ suite('Workbench - TerminalProcessManager', () => {
|
||||
instantiationService.stub(ITerminalInstanceService, new TestTerminalInstanceService());
|
||||
|
||||
const configHelper = instantiationService.createInstance(TerminalConfigHelper);
|
||||
manager = instantiationService.createInstance(TerminalProcessManager, 1, configHelper, undefined);
|
||||
manager = instantiationService.createInstance(TerminalProcessManager, 1, configHelper, undefined, undefined);
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
|
||||
Reference in New Issue
Block a user