diff --git a/src/vs/platform/terminal/common/terminal.ts b/src/vs/platform/terminal/common/terminal.ts index 1f14c55af2d..aac07d3387c 100644 --- a/src/vs/platform/terminal/common/terminal.ts +++ b/src/vs/platform/terminal/common/terminal.ts @@ -177,19 +177,19 @@ export enum TerminalIpcChannels { export const IPtyService = createDecorator('ptyService'); -export const enum TerminalPropertyType { - Cwd, - InitialCwd +export const enum ProcessPropertyType { + Cwd = 'cwd', + InitialCwd = 'initialCwd' } -export interface ITerminalProperty { +export interface IProcessProperty { type: T, - value: ITerminalPropertyMap[T] + value: IProcessPropertyMap[T] } -export interface ITerminalPropertyMap { - [TerminalPropertyType.Cwd]: string, - [TerminalPropertyType.InitialCwd]: string, +export interface IProcessPropertyMap { + [ProcessPropertyType.Cwd]: string, + [ProcessPropertyType.InitialCwd]: string, } export interface IPtyService { @@ -212,7 +212,7 @@ export interface IPtyService { readonly onProcessOrphanQuestion: Event<{ id: number }>; readonly onDidRequestDetach: Event<{ requestId: number, workspaceId: string, instanceId: number }>; readonly onProcessDidChangeHasChildProcesses: Event<{ id: number, event: boolean }>; - readonly onDidChangeProperty: Event<{ id: number, property: ITerminalProperty }> + readonly onDidChangeProperty: Event<{ id: number, property: IProcessProperty }> restartPtyHost?(): Promise; shutdownAll?(): Promise; @@ -262,7 +262,7 @@ export interface IPtyService { reduceConnectionGraceTime(): Promise; requestDetachInstance(workspaceId: string, instanceId: number): Promise; acceptDetachInstanceReply(requestId: number, persistentProcessId?: number): Promise; - refreshProperty(id: number, property: TerminalPropertyType): Promise; + refreshProperty(id: number, property: ProcessPropertyType): Promise; } export interface IRequestResolveVariablesEvent { @@ -489,7 +489,7 @@ export interface ITerminalChildProcess { onProcessOverrideDimensions?: Event; onProcessResolvedShellLaunchConfig?: Event; onDidChangeHasChildProcesses?: Event; - onDidChangeProperty: Event>; + onDidChangeProperty: Event>; /** * Starts the process. @@ -532,7 +532,7 @@ export interface ITerminalChildProcess { getInitialCwd(): Promise; getCwd(): Promise; getLatency(): Promise; - refreshProperty(property: TerminalPropertyType): Promise; + refreshProperty(property: ProcessPropertyType): Promise; } export interface IReconnectConstants { @@ -542,11 +542,6 @@ export interface IReconnectConstants { useExperimentalSerialization: boolean; } -export interface ITerminalProcessProperties { - cwd: string; - initialCwd: string -} - export const enum LocalReconnectConstants { /** * If there is no reconnection within this time-frame, consider the connection permanently closed... diff --git a/src/vs/platform/terminal/node/ptyHostService.ts b/src/vs/platform/terminal/node/ptyHostService.ts index 83766581723..184e83b9a0b 100644 --- a/src/vs/platform/terminal/node/ptyHostService.ts +++ b/src/vs/platform/terminal/node/ptyHostService.ts @@ -15,7 +15,7 @@ import { ILogService } from 'vs/platform/log/common/log'; import { LogLevelChannelClient } from 'vs/platform/log/common/logIpc'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { RequestStore } from 'vs/platform/terminal/common/requestStore'; -import { HeartbeatConstants, IHeartbeatService, IProcessDataEvent, IPtyService, IReconnectConstants, IRequestResolveVariablesEvent, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, ITerminalsLayoutInfo, TerminalIcon, TerminalIpcChannels, ITerminalProperty, TerminalShellType, TitleEventSource, TerminalPropertyType } from 'vs/platform/terminal/common/terminal'; +import { HeartbeatConstants, IHeartbeatService, IProcessDataEvent, IPtyService, IReconnectConstants, IRequestResolveVariablesEvent, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, ITerminalsLayoutInfo, TerminalIcon, TerminalIpcChannels, IProcessProperty, TerminalShellType, TitleEventSource, ProcessPropertyType } from 'vs/platform/terminal/common/terminal'; import { registerTerminalPlatformConfiguration } from 'vs/platform/terminal/common/terminalPlatformConfiguration'; import { IGetTerminalLayoutInfoArgs, IProcessDetails, IPtyHostProcessReplayEvent, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess'; import { detectAvailableProfiles } from 'vs/platform/terminal/node/terminalProfiles'; @@ -83,7 +83,7 @@ export class PtyHostService extends Disposable implements IPtyService { readonly onDidRequestDetach = this._onDidRequestDetach.event; private readonly _onProcessDidChangeHasChildProcesses = this._register(new Emitter<{ id: number, event: boolean }>()); readonly onProcessDidChangeHasChildProcesses = this._onProcessDidChangeHasChildProcesses.event; - private readonly _onDidChangeProperty = this._register(new Emitter<{ id: number, property: ITerminalProperty }>()); + private readonly _onDidChangeProperty = this._register(new Emitter<{ id: number, property: IProcessProperty }>()); readonly onDidChangeProperty = this._onDidChangeProperty.event; constructor( @@ -269,7 +269,7 @@ export class PtyHostService extends Disposable implements IPtyService { return this._proxy.acceptDetachInstanceReply(requestId, persistentProcessId); } - async refreshProperty(id: number, property: TerminalPropertyType): Promise { + async refreshProperty(id: number, property: ProcessPropertyType): Promise { return this._proxy.refreshProperty(id, property); } diff --git a/src/vs/platform/terminal/node/ptyService.ts b/src/vs/platform/terminal/node/ptyService.ts index 31115e2e4f1..8e15096044b 100644 --- a/src/vs/platform/terminal/node/ptyService.ts +++ b/src/vs/platform/terminal/node/ptyService.ts @@ -12,7 +12,7 @@ import { URI } from 'vs/base/common/uri'; import { getSystemShell } from 'vs/base/node/shell'; import { ILogService } from 'vs/platform/log/common/log'; import { RequestStore } from 'vs/platform/terminal/common/requestStore'; -import { IProcessDataEvent, IProcessReadyEvent, IPtyService, IRawTerminalInstanceLayoutInfo, IReconnectConstants, IRequestResolveVariablesEvent, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalInstanceLayoutInfoById, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalTabLayoutInfoById, TerminalIcon, ITerminalProperty, TerminalShellType, TitleEventSource, TerminalPropertyType } from 'vs/platform/terminal/common/terminal'; +import { IProcessDataEvent, IProcessReadyEvent, IPtyService, IRawTerminalInstanceLayoutInfo, IReconnectConstants, IRequestResolveVariablesEvent, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalInstanceLayoutInfoById, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalTabLayoutInfoById, TerminalIcon, IProcessProperty, TerminalShellType, TitleEventSource, ProcessPropertyType } from 'vs/platform/terminal/common/terminal'; import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering'; import { escapeNonWindowsPath } from 'vs/platform/terminal/common/terminalEnvironment'; import { Terminal as XtermTerminal } from 'xterm-headless'; @@ -60,7 +60,7 @@ export class PtyService extends Disposable implements IPtyService { readonly onDidRequestDetach = this._onDidRequestDetach.event; private readonly _onProcessDidChangeHasChildProcesses = this._register(new Emitter<{ id: number, event: boolean }>()); readonly onProcessDidChangeHasChildProcesses = this._onProcessDidChangeHasChildProcesses.event; - private readonly _onDidChangeProperty = this._register(new Emitter<{ id: number, property: ITerminalProperty }>()); + private readonly _onDidChangeProperty = this._register(new Emitter<{ id: number, property: IProcessProperty }>()); readonly onDidChangeProperty = this._onDidChangeProperty.event; constructor( @@ -165,7 +165,7 @@ export class PtyService extends Disposable implements IPtyService { this._throwIfNoPty(id).setIcon(icon, color); } - async refreshProperty(id: number, property: TerminalPropertyType): Promise { + async refreshProperty(id: number, property: ProcessPropertyType): Promise { return this._throwIfNoPty(id).refreshProperty(property); } @@ -347,7 +347,7 @@ export class PersistentTerminalProcess extends Disposable { readonly onProcessData = this._onProcessData.event; private readonly _onProcessOrphanQuestion = this._register(new Emitter()); readonly onProcessOrphanQuestion = this._onProcessOrphanQuestion.event; - private readonly _onDidChangeProperty = this._register(new Emitter>()); + private readonly _onDidChangeProperty = this._register(new Emitter>()); readonly onDidChangeProperty = this._onDidChangeProperty.event; private _inReplay = false; @@ -445,7 +445,7 @@ export class PersistentTerminalProcess extends Disposable { } } - async refreshProperty(property: TerminalPropertyType): Promise { + async refreshProperty(property: ProcessPropertyType): Promise { return this._terminalProcess.refreshProperty(property); } diff --git a/src/vs/platform/terminal/node/terminalProcess.ts b/src/vs/platform/terminal/node/terminalProcess.ts index 265a204531a..26c9106b963 100644 --- a/src/vs/platform/terminal/node/terminalProcess.ts +++ b/src/vs/platform/terminal/node/terminalProcess.ts @@ -15,7 +15,7 @@ import { URI } from 'vs/base/common/uri'; import { Promises } from 'vs/base/node/pfs'; import { localize } from 'vs/nls'; import { ILogService } from 'vs/platform/log/common/log'; -import { FlowControlConstants, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProcessProperties, ITerminalProperty, TerminalPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; +import { FlowControlConstants, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, IProcessProperty, IProcessPropertyMap as IProcessPropertyMap, ProcessPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; import { ChildProcessMonitor } from 'vs/platform/terminal/node/childProcessMonitor'; import { findExecutable, getWindowsBuildNumber } from 'vs/platform/terminal/node/terminalEnvironment'; import { WindowsShellHelper } from 'vs/platform/terminal/node/windowsShellHelper'; @@ -77,7 +77,10 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess readonly id = 0; readonly shouldPersist = false; - private _properties: ITerminalProcessProperties; + private _properties: IProcessPropertyMap = { + cwd: '', + initialCwd: '' + }; private static _lastKillOrStart = 0; private _exitCode: number | undefined; private _exitMessage: string | undefined; @@ -114,7 +117,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess readonly onProcessShellTypeChanged = this._onProcessShellTypeChanged.event; private readonly _onDidChangeHasChildProcesses = this._register(new Emitter()); readonly onDidChangeHasChildProcesses = this._onDidChangeHasChildProcesses.event; - private readonly _onDidChangeProperty = this._register(new Emitter>()); + private readonly _onDidChangeProperty = this._register(new Emitter>()); readonly onDidChangeProperty = this._onDidChangeProperty.event; onProcessOverrideDimensions?: Event | undefined; @@ -143,10 +146,9 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess name = 'xterm-256color'; } this._initialCwd = cwd; - this._properties = { - cwd: this._initialCwd, - initialCwd: this._initialCwd - }; + this._properties[ProcessPropertyType.InitialCwd] = this._initialCwd; + this._properties[ProcessPropertyType.Cwd] = this._initialCwd; + const useConpty = windowsEnableConpty && process.platform === 'win32' && getWindowsBuildNumber() >= 18309; this._ptyOptions = { name, @@ -207,7 +209,7 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess return { message: localize('launchFail.cwdDoesNotExist', "Starting directory (cwd) \"{0}\" does not exist", this._initialCwd.toString()) }; } } - this._onDidChangeProperty.fire({ type: TerminalPropertyType.InitialCwd, value: this._initialCwd }); + this._onDidChangeProperty.fire({ type: ProcessPropertyType.InitialCwd, value: this._initialCwd }); return undefined; } @@ -393,14 +395,14 @@ export class TerminalProcess extends Disposable implements ITerminalChildProcess this.input(data, true); } - async refreshProperty(property: TerminalPropertyType): Promise { - if (property === TerminalPropertyType.Cwd) { + async refreshProperty(property: ProcessPropertyType): Promise { + if (property === ProcessPropertyType.Cwd) { const newCwd = await this.getCwd(); - if (newCwd !== this._properties.cwd || this._properties.cwd === '') { + if (newCwd !== this._properties.cwd) { this._properties.cwd = newCwd; - this._onDidChangeProperty.fire({ type: TerminalPropertyType.Cwd, value: this._properties.cwd }); + this._onDidChangeProperty.fire({ type: ProcessPropertyType.Cwd, value: this._properties.cwd }); } - } else if (property === TerminalPropertyType.InitialCwd) { + } else if (property === ProcessPropertyType.InitialCwd) { return this.getInitialCwd(); } } diff --git a/src/vs/workbench/api/common/extHostTerminalService.ts b/src/vs/workbench/api/common/extHostTerminalService.ts index 5a2435d991a..2276223430e 100644 --- a/src/vs/workbench/api/common/extHostTerminalService.ts +++ b/src/vs/workbench/api/common/extHostTerminalService.ts @@ -18,7 +18,7 @@ import { serializeEnvironmentVariableCollection } from 'vs/workbench/contrib/ter import { CancellationTokenSource } from 'vs/base/common/cancellation'; import { generateUuid } from 'vs/base/common/uuid'; import { ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable'; -import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, ITerminalProperty, TerminalShellType, IShellLaunchConfig, TerminalPropertyType } from 'vs/platform/terminal/common/terminal'; +import { ICreateContributedTerminalProfileOptions, IProcessReadyEvent, IShellLaunchConfigDto, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, TerminalIcon, TerminalLocation, IProcessProperty, TerminalShellType, IShellLaunchConfig, ProcessPropertyType } from 'vs/platform/terminal/common/terminal'; import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering'; import { ThemeColor } from 'vs/platform/theme/common/themeService'; import { withNullAsUndefined } from 'vs/base/common/types'; @@ -250,7 +250,7 @@ export class ExtHostPseudoterminal implements ITerminalChildProcess { public get onProcessOverrideDimensions(): Event { return this._onProcessOverrideDimensions.event; } private readonly _onProcessShellTypeChanged = new Emitter(); public readonly onProcessShellTypeChanged = this._onProcessShellTypeChanged.event; - private readonly _onDidChangeProperty = new Emitter>(); + private readonly _onDidChangeProperty = new Emitter>(); public readonly onDidChangeProperty = this._onDidChangeProperty.event; @@ -258,7 +258,7 @@ export class ExtHostPseudoterminal implements ITerminalChildProcess { onProcessResolvedShellLaunchConfig?: Event | undefined; onDidChangeHasChildProcesses?: Event | undefined; - refreshProperty(property: TerminalPropertyType): Promise { + refreshProperty(property: ProcessPropertyType): Promise { return Promise.resolve(''); } diff --git a/src/vs/workbench/contrib/terminal/browser/remotePty.ts b/src/vs/workbench/contrib/terminal/browser/remotePty.ts index c96ec3c1e5e..1615c204921 100644 --- a/src/vs/workbench/contrib/terminal/browser/remotePty.ts +++ b/src/vs/workbench/contrib/terminal/browser/remotePty.ts @@ -8,7 +8,7 @@ import { Emitter } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import { URI } from 'vs/base/common/uri'; import { ILogService } from 'vs/platform/log/common/log'; -import { IProcessDataEvent, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProcessProperties, ITerminalProperty, TerminalPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; +import { IProcessDataEvent, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, IProcessProperty, IProcessPropertyMap, ProcessPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; import { IPtyHostProcessReplayEvent } from 'vs/platform/terminal/common/terminalProcess'; import { RemoteTerminalChannelClient } from 'vs/workbench/contrib/terminal/common/remoteTerminalChannel'; import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; @@ -30,14 +30,17 @@ export class RemotePty extends Disposable implements ITerminalChildProcess { readonly onProcessResolvedShellLaunchConfig = this._onProcessResolvedShellLaunchConfig.event; private readonly _onDidChangeHasChildProcesses = this._register(new Emitter()); readonly onDidChangeHasChildProcesses = this._onDidChangeHasChildProcesses.event; - private readonly _onDidChangeProperty = this._register(new Emitter>()); + private readonly _onDidChangeProperty = this._register(new Emitter>()); readonly onDidChangeProperty = this._onDidChangeProperty.event; private _startBarrier: Barrier; private _inReplay = false; - private _properties: ITerminalProcessProperties; + private _properties: IProcessPropertyMap = { + cwd: '', + initialCwd: '' + }; get id(): number { return this._id; } @@ -50,10 +53,6 @@ export class RemotePty extends Disposable implements ITerminalChildProcess { ) { super(); this._startBarrier = new Barrier(); - this._properties = { - cwd: '', - initialCwd: '' - }; } async start(): Promise { @@ -131,7 +130,7 @@ export class RemotePty extends Disposable implements ITerminalChildProcess { return this._properties.cwd || this._properties.initialCwd; } - async refreshProperty(property: TerminalPropertyType): Promise { + async refreshProperty(property: ProcessPropertyType): Promise { this._remoteTerminalChannel.refreshProperty(this._id, property); } @@ -166,10 +165,10 @@ export class RemotePty extends Disposable implements ITerminalChildProcess { handleDidChangeHasChildProcesses(e: boolean) { this._onDidChangeHasChildProcesses.fire(e); } - handleDidChangeProperty(e: ITerminalProperty) { - if (e.type === TerminalPropertyType.Cwd) { + handleDidChangeProperty(e: IProcessProperty) { + if (e.type === ProcessPropertyType.Cwd) { this._properties.cwd = e.value; - } else if (e.type === TerminalPropertyType.InitialCwd) { + } else if (e.type === ProcessPropertyType.InitialCwd) { this._properties.initialCwd = e.value; } this._onDidChangeProperty.fire(e); diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 24a6e94eb6e..976cec01f7e 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -46,7 +46,7 @@ import { TypeAheadAddon } from 'vs/workbench/contrib/terminal/browser/terminalTy import { BrowserFeatures } from 'vs/base/browser/canIUse'; import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences'; import { IEnvironmentVariableInfo } from 'vs/workbench/contrib/terminal/common/environmentVariable'; -import { IProcessDataEvent, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalLaunchError, TerminalShellType, TerminalSettingId, TitleEventSource, TerminalIcon, TerminalSettingPrefix, ITerminalProfileObject, TerminalLocation, TerminalPropertyType } from 'vs/platform/terminal/common/terminal'; +import { IProcessDataEvent, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalLaunchError, TerminalShellType, TerminalSettingId, TitleEventSource, TerminalIcon, TerminalSettingPrefix, ITerminalProfileObject, TerminalLocation, ProcessPropertyType } from 'vs/platform/terminal/common/terminal'; import { IProductService } from 'vs/platform/product/common/productService'; import { formatMessageForTerminal } from 'vs/workbench/contrib/terminal/common/terminalStrings'; import { AutoOpenBarrier } from 'vs/base/common/async'; @@ -1160,7 +1160,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { // Set the initial name based on the _resolved_ shell launch config, this will also // ensure the resolved icon gets shown this._processManager.onDidChangeProperty(e => { - if (e.type === TerminalPropertyType.Cwd || e.type === TerminalPropertyType.InitialCwd) { + if (e.type === ProcessPropertyType.Cwd || e.type === ProcessPropertyType.InitialCwd) { this._cwd = e.value; this.setTitle(this.title, TitleEventSource.Api); } @@ -1960,7 +1960,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { } getCwd(): Promise { - return this._processManager.refreshProperty(TerminalPropertyType.Cwd); + return this._processManager.refreshProperty(ProcessPropertyType.Cwd); } registerLinkProvider(provider: ITerminalExternalLinkProvider): IDisposable { diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts b/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts index 54dda115e7d..ab0e5d83ead 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProcessExtHostProxy.ts @@ -5,7 +5,7 @@ import { Emitter, Event } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; -import { IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensions, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProperty, TerminalPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; +import { IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensions, ITerminalDimensionsOverride, ITerminalLaunchError, IProcessProperty, ProcessPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; import { ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal'; import { ITerminalProcessExtHostProxy } from 'vs/workbench/contrib/terminal/common/terminal'; @@ -46,7 +46,7 @@ export class TerminalProcessExtHostProxy extends Disposable implements ITerminal readonly onRequestLatency: Event = this._onRequestLatency.event; private readonly _onProcessShellTypeChanged = this._register(new Emitter()); readonly onProcessShellTypeChanged = this._onProcessShellTypeChanged.event; - private readonly _onDidChangeProperty = this._register(new Emitter>()); + private readonly _onDidChangeProperty = this._register(new Emitter>()); readonly onDidChangeProperty = this._onDidChangeProperty.event; @@ -157,10 +157,10 @@ export class TerminalProcessExtHostProxy extends Disposable implements ITerminal }); } - async refreshProperty(property: TerminalPropertyType): Promise { - if (property === TerminalPropertyType.Cwd) { + async refreshProperty(type: ProcessPropertyType): Promise { + if (type === ProcessPropertyType.Cwd) { return this.getCwd(); - } else if (property === TerminalPropertyType.InitialCwd) { + } else if (type === ProcessPropertyType.InitialCwd) { return this.getInitialCwd(); } } diff --git a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts index 061b8cb58f6..fda43cfbeeb 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.ts @@ -22,7 +22,7 @@ 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, ITerminalDimensionsOverride, ITerminalEnvironment, ITerminalLaunchError, FlowControlConstants, TerminalShellType, ITerminalDimensions, TerminalSettingId, IProcessReadyEvent, ITerminalProperty, TerminalPropertyType } from 'vs/platform/terminal/common/terminal'; +import { IProcessDataEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalEnvironment, ITerminalLaunchError, FlowControlConstants, TerminalShellType, ITerminalDimensions, TerminalSettingId, IProcessReadyEvent, IProcessProperty, ProcessPropertyType } 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'; @@ -96,7 +96,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce readonly onProcessData = this._onProcessData.event; private readonly _onProcessTitle = this._register(new Emitter()); readonly onProcessTitle = this._onProcessTitle.event; - private readonly _onDidChangeProperty = this._register(new Emitter>()); + private readonly _onDidChangeProperty = this._register(new Emitter>()); readonly onDidChangeProperty = this._onDidChangeProperty.event; private readonly _onProcessShellTypeChanged = this._register(new Emitter()); readonly onProcessShellTypeChanged = this._onProcessShellTypeChanged.event; @@ -562,7 +562,7 @@ export class TerminalProcessManager extends Disposable implements ITerminalProce return Promise.resolve(this._latency); } - async refreshProperty(property: TerminalPropertyType): Promise { + async refreshProperty(property: ProcessPropertyType): Promise { return this._process?.refreshProperty(property); } diff --git a/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts b/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts index f03f4788acc..8b9ea13e60e 100644 --- a/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts +++ b/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts @@ -18,7 +18,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic import { Schemas } from 'vs/base/common/network'; import { ILabelService } from 'vs/platform/label/common/label'; import { IEnvironmentVariableService, ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable'; -import { IProcessDataEvent, IRequestResolveVariablesEvent, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalDimensionsOverride, ITerminalEnvironment, ITerminalLaunchError, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalIcon, ITerminalProperty, TerminalShellType, TerminalPropertyType } from 'vs/platform/terminal/common/terminal'; +import { IProcessDataEvent, IRequestResolveVariablesEvent, IShellLaunchConfig, IShellLaunchConfigDto, ITerminalDimensionsOverride, ITerminalEnvironment, ITerminalLaunchError, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalIcon, IProcessProperty, TerminalShellType, ProcessPropertyType } from 'vs/platform/terminal/common/terminal'; import { IGetTerminalLayoutInfoArgs, IProcessDetails, IPtyHostProcessReplayEvent, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess'; import { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform'; @@ -124,8 +124,8 @@ export class RemoteTerminalChannelClient { get onDidRequestDetach(): Event<{ requestId: number, workspaceId: string, instanceId: number }> { return this._channel.listen<{ requestId: number, workspaceId: string, instanceId: number }>('$onDidRequestDetach'); } - get onDidChangeProperty(): Event<{ id: number, property: ITerminalProperty }> { - return this._channel.listen<{ id: number, property: ITerminalProperty }>('$onDidChangeProperty'); + get onDidChangeProperty(): Event<{ id: number, property: IProcessProperty }> { + return this._channel.listen<{ id: number, property: IProcessProperty }>('$onDidChangeProperty'); } constructor( @@ -293,7 +293,7 @@ export class RemoteTerminalChannelClient { return this._channel.call('$updateIcon', [id, icon, color]); } - refreshProperty(id: number, property: TerminalPropertyType): Promise { + refreshProperty(id: number, property: ProcessPropertyType): Promise { return this._channel.call('$refreshProperty', [id, property]); } diff --git a/src/vs/workbench/contrib/terminal/common/terminal.ts b/src/vs/workbench/contrib/terminal/common/terminal.ts index ec5487461ae..20cdc3ec408 100644 --- a/src/vs/workbench/contrib/terminal/common/terminal.ts +++ b/src/vs/workbench/contrib/terminal/common/terminal.ts @@ -8,7 +8,7 @@ import { Event } from 'vs/base/common/event'; import { IDisposable } from 'vs/base/common/lifecycle'; import { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform'; import { IExtensionPointDescriptor } from 'vs/workbench/services/extensions/common/extensionsRegistry'; -import { IProcessDataEvent, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensions, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, ITerminalProfileObject, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalIcon, TerminalLocationString, ITerminalProperty, TerminalShellType, TitleEventSource, TerminalPropertyType } from 'vs/platform/terminal/common/terminal'; +import { IProcessDataEvent, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensions, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, ITerminalProfileObject, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalIcon, TerminalLocationString, IProcessProperty, TerminalShellType, TitleEventSource, ProcessPropertyType } from 'vs/platform/terminal/common/terminal'; import { IEnvironmentVariableInfo } from 'vs/workbench/contrib/terminal/common/environmentVariable'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { URI } from 'vs/base/common/uri'; @@ -297,7 +297,7 @@ export interface ITerminalProcessManager extends IDisposable { readonly onProcessResolvedShellLaunchConfig: Event; readonly onProcessDidChangeHasChildProcesses: Event; readonly onEnvironmentVariableInfoChanged: Event; - readonly onDidChangeProperty: Event>; + readonly onDidChangeProperty: Event>; dispose(immediate?: boolean): void; detachFromProcess(): Promise; @@ -314,7 +314,7 @@ export interface ITerminalProcessManager extends IDisposable { getInitialCwd(): Promise; getCwd(): Promise; getLatency(): Promise; - refreshProperty(property: TerminalPropertyType): any; + refreshProperty(property: ProcessPropertyType): any; } export const enum ProcessState { diff --git a/src/vs/workbench/contrib/terminal/electron-sandbox/localPty.ts b/src/vs/workbench/contrib/terminal/electron-sandbox/localPty.ts index 1a54c6cbd62..b0180b832cf 100644 --- a/src/vs/workbench/contrib/terminal/electron-sandbox/localPty.ts +++ b/src/vs/workbench/contrib/terminal/electron-sandbox/localPty.ts @@ -6,7 +6,7 @@ import { Emitter } from 'vs/base/common/event'; import { Disposable } from 'vs/base/common/lifecycle'; import { ILocalPtyService } from 'vs/platform/terminal/electron-sandbox/terminal'; -import { IProcessDataEvent, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProcessProperties, ITerminalProperty, TerminalPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; +import { IProcessDataEvent, IProcessReadyEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, IProcessProperty, IProcessPropertyMap, ProcessPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; import { IPtyHostProcessReplayEvent } from 'vs/platform/terminal/common/terminalProcess'; /** @@ -15,7 +15,10 @@ import { IPtyHostProcessReplayEvent } from 'vs/platform/terminal/common/terminal */ export class LocalPty extends Disposable implements ITerminalChildProcess { private _inReplay = false; - private _properties: ITerminalProcessProperties; + private _properties: IProcessPropertyMap = { + cwd: '', + initialCwd: '' + }; private readonly _onProcessData = this._register(new Emitter()); readonly onProcessData = this._onProcessData.event; private readonly _onProcessReplay = this._register(new Emitter()); @@ -34,7 +37,7 @@ export class LocalPty extends Disposable implements ITerminalChildProcess { readonly onProcessShellTypeChanged = this._onProcessShellTypeChanged.event; private readonly _onDidChangeHasChildProcesses = this._register(new Emitter()); readonly onDidChangeHasChildProcesses = this._onDidChangeHasChildProcesses.event; - private readonly _onDidChangeProperty = this._register(new Emitter>()); + private readonly _onDidChangeProperty = this._register(new Emitter>()); readonly onDidChangeProperty = this._onDidChangeProperty.event; constructor( @@ -43,10 +46,6 @@ export class LocalPty extends Disposable implements ITerminalChildProcess { @ILocalPtyService private readonly _localPtyService: ILocalPtyService ) { super(); - this._properties = { - cwd: '', - initialCwd: '' - }; } start(): Promise { @@ -82,7 +81,7 @@ export class LocalPty extends Disposable implements ITerminalChildProcess { async getCwd(): Promise { return this._properties.cwd || this._properties.initialCwd; } - async refreshProperty(property: TerminalPropertyType): Promise { + async refreshProperty(property: ProcessPropertyType): Promise { this._localPtyService.refreshProperty(this.id, property); } getLatency(): Promise { @@ -123,10 +122,10 @@ export class LocalPty extends Disposable implements ITerminalChildProcess { handleDidChangeHasChildProcesses(e: boolean) { this._onDidChangeHasChildProcesses.fire(e); } - handleDidChangeProperty(e: ITerminalProperty) { - if (e.type === TerminalPropertyType.Cwd) { + handleDidChangeProperty(e: IProcessProperty) { + if (e.type === ProcessPropertyType.Cwd) { this._properties.cwd = e.value; - } else if (e.type === TerminalPropertyType.InitialCwd) { + } else if (e.type === ProcessPropertyType.InitialCwd) { this._properties.initialCwd = e.value; } this._onDidChangeProperty.fire(e); diff --git a/src/vs/workbench/contrib/testing/browser/testingOutputTerminalService.ts b/src/vs/workbench/contrib/testing/browser/testingOutputTerminalService.ts index cf70a673139..4144fe9cac5 100644 --- a/src/vs/workbench/contrib/testing/browser/testingOutputTerminalService.ts +++ b/src/vs/workbench/contrib/testing/browser/testingOutputTerminalService.ts @@ -10,7 +10,7 @@ import { listenStream } from 'vs/base/common/stream'; import { isDefined } from 'vs/base/common/types'; import { localize } from 'vs/nls'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -import { IProcessDataEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, TerminalPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; +import { IProcessDataEvent, IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalLaunchError, ProcessPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; import { IViewsService } from 'vs/workbench/common/views'; import { ITerminalGroupService, ITerminalInstance, ITerminalService } from 'vs/workbench/contrib/terminal/browser/terminal'; import { TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal'; @@ -224,7 +224,7 @@ class TestOutputProcess extends Disposable implements ITerminalChildProcess { return Promise.resolve(0); } - refreshProperty(property: TerminalPropertyType) { + refreshProperty(property: ProcessPropertyType) { return Promise.resolve(''); } //#endregion diff --git a/src/vs/workbench/test/browser/workbenchTestServices.ts b/src/vs/workbench/test/browser/workbenchTestServices.ts index 0797423a659..7ffa65d7ca2 100644 --- a/src/vs/workbench/test/browser/workbenchTestServices.ts +++ b/src/vs/workbench/test/browser/workbenchTestServices.ts @@ -126,7 +126,7 @@ import { SideBySideEditor } from 'vs/workbench/browser/parts/editor/sideBySideEd import { IEnterWorkspaceResult, IRecent, IRecentlyOpened, IWorkspaceFolderCreationData, IWorkspaceIdentifier, IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspaceTrustManagementService, IWorkspaceTrustRequestService } from 'vs/platform/workspace/common/workspaceTrust'; import { TestWorkspaceTrustManagementService, TestWorkspaceTrustRequestService } from 'vs/workbench/services/workspaces/test/common/testWorkspaceTrustService'; -import { IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalLocation, TerminalPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; +import { IShellLaunchConfig, ITerminalChildProcess, ITerminalDimensionsOverride, ITerminalProfile, ITerminalsLayoutInfo, ITerminalsLayoutInfoById, TerminalLocation, ProcessPropertyType, TerminalShellType } from 'vs/platform/terminal/common/terminal'; import { IProcessDetails, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess'; import { ICreateTerminalOptions, ITerminalInstance, ITerminalInstanceService } from 'vs/workbench/contrib/terminal/browser/terminal'; import { isArray } from 'vs/base/common/types'; @@ -1726,7 +1726,7 @@ class TestTerminalChildProcess implements ITerminalChildProcess { async getCwd(): Promise { return ''; } async getLatency(): Promise { return 0; } async processBinary(data: string): Promise { } - refreshProperty(property: TerminalPropertyType): Promise { return Promise.resolve(''); } + refreshProperty(property: ProcessPropertyType): Promise { return Promise.resolve(''); } } export class TestQuickInputService implements IQuickInputService {