Skip to content

Commit 5e10a96

Browse files
authored
Revert "fix extension pty terminal test failures (microsoft#135672)" (microsoft#135685)
This reverts commit af0c034.
1 parent af0c034 commit 5e10a96

18 files changed

+386
-248
lines changed

src/vs/platform/terminal/common/terminal.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,7 @@ export const IPtyService = createDecorator<IPtyService>('ptyService');
181181
export const enum ProcessPropertyType {
182182
Cwd = 'cwd',
183183
InitialCwd = 'initialCwd',
184-
FixedDimensions = 'fixedDimensions',
185-
Title = 'title',
186-
ShellType = 'shellType',
187-
HasChildProcesses = 'hasChildProcesses',
188-
ResolvedShellLaunchConfig = 'resolvedShellLaunchConfig',
189-
OverrideDimensions = 'overrideDimensions',
190-
Exit = 'exit'
184+
FixedDimensions = 'fixedDimensions'
191185
}
192186

193187
export interface IProcessProperty<T extends ProcessPropertyType> {
@@ -198,13 +192,7 @@ export interface IProcessProperty<T extends ProcessPropertyType> {
198192
export interface IProcessPropertyMap {
199193
[ProcessPropertyType.Cwd]: string,
200194
[ProcessPropertyType.InitialCwd]: string,
201-
[ProcessPropertyType.FixedDimensions]: IFixedTerminalDimensions,
202-
[ProcessPropertyType.Title]: string
203-
[ProcessPropertyType.ShellType]: TerminalShellType | undefined,
204-
[ProcessPropertyType.HasChildProcesses]: boolean,
205-
[ProcessPropertyType.ResolvedShellLaunchConfig]: IShellLaunchConfig,
206-
[ProcessPropertyType.OverrideDimensions]: ITerminalDimensionsOverride | undefined,
207-
[ProcessPropertyType.Exit]: number | undefined
195+
[ProcessPropertyType.FixedDimensions]: IFixedTerminalDimensions
208196
}
209197

210198
export interface IFixedTerminalDimensions {
@@ -230,10 +218,16 @@ export interface IPtyService {
230218
readonly onPtyHostRequestResolveVariables?: Event<IRequestResolveVariablesEvent>;
231219

232220
readonly onProcessData: Event<{ id: number, event: IProcessDataEvent | string }>;
233-
readonly onProcessReady: Event<{ id: number, event: IProcessReadyEvent }>;
221+
readonly onProcessExit: Event<{ id: number, event: number | undefined }>;
222+
readonly onProcessReady: Event<{ id: number, event: { pid: number, cwd: string, capabilities: ProcessCapability[] } }>;
223+
readonly onProcessTitleChanged: Event<{ id: number, event: string }>;
224+
readonly onProcessShellTypeChanged: Event<{ id: number, event: TerminalShellType }>;
225+
readonly onProcessOverrideDimensions: Event<{ id: number, event: ITerminalDimensionsOverride | undefined }>;
226+
readonly onProcessResolvedShellLaunchConfig: Event<{ id: number, event: IShellLaunchConfig }>;
234227
readonly onProcessReplay: Event<{ id: number, event: IPtyHostProcessReplayEvent }>;
235228
readonly onProcessOrphanQuestion: Event<{ id: number }>;
236229
readonly onDidRequestDetach: Event<{ requestId: number, workspaceId: string, instanceId: number }>;
230+
readonly onProcessDidChangeHasChildProcesses: Event<{ id: number, event: boolean }>;
237231
readonly onDidChangeProperty: Event<{ id: number, property: IProcessProperty<any> }>
238232

239233
restartPtyHost?(): Promise<void>;
@@ -533,7 +527,13 @@ export interface ITerminalChildProcess {
533527
capabilities: ProcessCapability[];
534528

535529
onProcessData: Event<IProcessDataEvent | string>;
530+
onProcessExit: Event<number | undefined>;
536531
onProcessReady: Event<IProcessReadyEvent>;
532+
onProcessTitleChanged: Event<string>;
533+
onProcessShellTypeChanged: Event<TerminalShellType>;
534+
onProcessOverrideDimensions?: Event<ITerminalDimensionsOverride | undefined>;
535+
onProcessResolvedShellLaunchConfig?: Event<IShellLaunchConfig>;
536+
onDidChangeHasChildProcesses?: Event<boolean>;
537537
onDidChangeProperty: Event<IProcessProperty<any>>;
538538

539539
/**

src/vs/platform/terminal/node/ptyHostService.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { ILogService } from 'vs/platform/log/common/log';
1717
import { LogLevelChannelClient } from 'vs/platform/log/common/logIpc';
1818
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
1919
import { RequestStore } from 'vs/platform/terminal/common/requestStore';
20-
import { HeartbeatConstants, IHeartbeatService, IProcessDataEvent, IPtyService, IReconnectConstants, IRequestResolveVariablesEvent, IShellLaunchConfig, ITerminalLaunchError, ITerminalProfile, ITerminalsLayoutInfo, TerminalIcon, TerminalIpcChannels, IProcessProperty, TitleEventSource, ProcessPropertyType, ProcessCapability, IProcessPropertyMap, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
20+
import { HeartbeatConstants, IHeartbeatService, IProcessDataEvent, IPtyService, IReconnectConstants, IRequestResolveVariablesEvent, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalLaunchError, ITerminalProfile, ITerminalsLayoutInfo, TerminalIcon, TerminalIpcChannels, IProcessProperty, TerminalShellType, TitleEventSource, ProcessPropertyType, ProcessCapability, IProcessPropertyMap, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
2121
import { registerTerminalPlatformConfiguration } from 'vs/platform/terminal/common/terminalPlatformConfiguration';
2222
import { IGetTerminalLayoutInfoArgs, IProcessDetails, IPtyHostProcessReplayEvent, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
2323
import { detectAvailableProfiles } from 'vs/platform/terminal/node/terminalProfiles';
@@ -64,14 +64,26 @@ export class PtyHostService extends Disposable implements IPtyService {
6464

6565
private readonly _onProcessData = this._register(new Emitter<{ id: number, event: IProcessDataEvent | string }>());
6666
readonly onProcessData = this._onProcessData.event;
67+
private readonly _onProcessExit = this._register(new Emitter<{ id: number, event: number | undefined }>());
68+
readonly onProcessExit = this._onProcessExit.event;
6769
private readonly _onProcessReady = this._register(new Emitter<{ id: number, event: { pid: number, cwd: string, capabilities: ProcessCapability[] } }>());
6870
readonly onProcessReady = this._onProcessReady.event;
6971
private readonly _onProcessReplay = this._register(new Emitter<{ id: number, event: IPtyHostProcessReplayEvent }>());
7072
readonly onProcessReplay = this._onProcessReplay.event;
73+
private readonly _onProcessTitleChanged = this._register(new Emitter<{ id: number, event: string }>());
74+
readonly onProcessTitleChanged = this._onProcessTitleChanged.event;
75+
private readonly _onProcessShellTypeChanged = this._register(new Emitter<{ id: number, event: TerminalShellType }>());
76+
readonly onProcessShellTypeChanged = this._onProcessShellTypeChanged.event;
77+
private readonly _onProcessOverrideDimensions = this._register(new Emitter<{ id: number, event: ITerminalDimensionsOverride | undefined }>());
78+
readonly onProcessOverrideDimensions = this._onProcessOverrideDimensions.event;
79+
private readonly _onProcessResolvedShellLaunchConfig = this._register(new Emitter<{ id: number, event: IShellLaunchConfig }>());
80+
readonly onProcessResolvedShellLaunchConfig = this._onProcessResolvedShellLaunchConfig.event;
7181
private readonly _onProcessOrphanQuestion = this._register(new Emitter<{ id: number }>());
7282
readonly onProcessOrphanQuestion = this._onProcessOrphanQuestion.event;
7383
private readonly _onDidRequestDetach = this._register(new Emitter<{ requestId: number, workspaceId: string, instanceId: number }>());
7484
readonly onDidRequestDetach = this._onDidRequestDetach.event;
85+
private readonly _onProcessDidChangeHasChildProcesses = this._register(new Emitter<{ id: number, event: boolean }>());
86+
readonly onProcessDidChangeHasChildProcesses = this._onProcessDidChangeHasChildProcesses.event;
7587
private readonly _onDidChangeProperty = this._register(new Emitter<{ id: number, property: IProcessProperty<any> }>());
7688
readonly onDidChangeProperty = this._onDidChangeProperty.event;
7789

@@ -190,7 +202,13 @@ export class PtyHostService extends Disposable implements IPtyService {
190202
// Create proxy and forward events
191203
const proxy = ProxyChannel.toService<IPtyService>(client.getChannel(TerminalIpcChannels.PtyHost));
192204
this._register(proxy.onProcessData(e => this._onProcessData.fire(e)));
205+
this._register(proxy.onProcessExit(e => this._onProcessExit.fire(e)));
193206
this._register(proxy.onProcessReady(e => this._onProcessReady.fire(e)));
207+
this._register(proxy.onProcessTitleChanged(e => this._onProcessTitleChanged.fire(e)));
208+
this._register(proxy.onProcessShellTypeChanged(e => this._onProcessShellTypeChanged.fire(e)));
209+
this._register(proxy.onProcessOverrideDimensions(e => this._onProcessOverrideDimensions.fire(e)));
210+
this._register(proxy.onProcessResolvedShellLaunchConfig(e => this._onProcessResolvedShellLaunchConfig.fire(e)));
211+
this._register(proxy.onProcessDidChangeHasChildProcesses(e => this._onProcessDidChangeHasChildProcesses.fire(e)));
194212
this._register(proxy.onDidChangeProperty(e => this._onDidChangeProperty.fire(e)));
195213
this._register(proxy.onProcessReplay(e => this._onProcessReplay.fire(e)));
196214
this._register(proxy.onProcessOrphanQuestion(e => this._onProcessOrphanQuestion.fire(e)));

src/vs/platform/terminal/node/ptyService.ts

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { URI } from 'vs/base/common/uri';
1212
import { getSystemShell } from 'vs/base/node/shell';
1313
import { ILogService } from 'vs/platform/log/common/log';
1414
import { RequestStore } from 'vs/platform/terminal/common/requestStore';
15-
import { IProcessDataEvent, IProcessReadyEvent, IPtyService, IRawTerminalInstanceLayoutInfo, IReconnectConstants, IRequestResolveVariablesEvent, IShellLaunchConfig, ITerminalInstanceLayoutInfoById, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalTabLayoutInfoById, TerminalIcon, IProcessProperty, TitleEventSource, ProcessPropertyType, IProcessPropertyMap, IFixedTerminalDimensions, ProcessCapability } from 'vs/platform/terminal/common/terminal';
15+
import { IProcessDataEvent, IProcessReadyEvent, IPtyService, IRawTerminalInstanceLayoutInfo, IReconnectConstants, IRequestResolveVariablesEvent, IShellLaunchConfig, ITerminalDimensionsOverride, ITerminalInstanceLayoutInfoById, ITerminalLaunchError, ITerminalsLayoutInfo, ITerminalTabLayoutInfoById, TerminalIcon, IProcessProperty, TerminalShellType, TitleEventSource, ProcessPropertyType, ProcessCapability, IProcessPropertyMap, IFixedTerminalDimensions } from 'vs/platform/terminal/common/terminal';
1616
import { TerminalDataBufferer } from 'vs/platform/terminal/common/terminalDataBuffering';
1717
import { escapeNonWindowsPath } from 'vs/platform/terminal/common/terminalEnvironment';
1818
import { Terminal as XtermTerminal } from 'xterm-headless';
@@ -44,12 +44,24 @@ export class PtyService extends Disposable implements IPtyService {
4444
readonly onProcessData = this._onProcessData.event;
4545
private readonly _onProcessReplay = this._register(new Emitter<{ id: number, event: IPtyHostProcessReplayEvent }>());
4646
readonly onProcessReplay = this._onProcessReplay.event;
47+
private readonly _onProcessExit = this._register(new Emitter<{ id: number, event: number | undefined }>());
48+
readonly onProcessExit = this._onProcessExit.event;
4749
private readonly _onProcessReady = this._register(new Emitter<{ id: number, event: { pid: number, cwd: string, capabilities: ProcessCapability[] } }>());
4850
readonly onProcessReady = this._onProcessReady.event;
51+
private readonly _onProcessTitleChanged = this._register(new Emitter<{ id: number, event: string }>());
52+
readonly onProcessTitleChanged = this._onProcessTitleChanged.event;
53+
private readonly _onProcessShellTypeChanged = this._register(new Emitter<{ id: number, event: TerminalShellType }>());
54+
readonly onProcessShellTypeChanged = this._onProcessShellTypeChanged.event;
55+
private readonly _onProcessOverrideDimensions = this._register(new Emitter<{ id: number, event: ITerminalDimensionsOverride | undefined }>());
56+
readonly onProcessOverrideDimensions = this._onProcessOverrideDimensions.event;
57+
private readonly _onProcessResolvedShellLaunchConfig = this._register(new Emitter<{ id: number, event: IShellLaunchConfig }>());
58+
readonly onProcessResolvedShellLaunchConfig = this._onProcessResolvedShellLaunchConfig.event;
4959
private readonly _onProcessOrphanQuestion = this._register(new Emitter<{ id: number }>());
5060
readonly onProcessOrphanQuestion = this._onProcessOrphanQuestion.event;
5161
private readonly _onDidRequestDetach = this._register(new Emitter<{ requestId: number, workspaceId: string, instanceId: number }>());
5262
readonly onDidRequestDetach = this._onDidRequestDetach.event;
63+
private readonly _onProcessDidChangeHasChildProcesses = this._register(new Emitter<{ id: number, event: boolean }>());
64+
readonly onProcessDidChangeHasChildProcesses = this._onProcessDidChangeHasChildProcesses.event;
5365
private readonly _onDidChangeProperty = this._register(new Emitter<{ id: number, property: IProcessProperty<any> }>());
5466
readonly onDidChangeProperty = this._onDidChangeProperty.event;
5567

@@ -183,21 +195,31 @@ export class PtyService extends Disposable implements IPtyService {
183195
const id = ++this._lastPtyId;
184196
const process = new TerminalProcess(shellLaunchConfig, cwd, cols, rows, env, executableEnv, windowsEnableConpty, this._logService);
185197
process.onProcessData(event => this._onProcessData.fire({ id, event }));
198+
process.onProcessExit(event => this._onProcessExit.fire({ id, event }));
199+
if (process.onProcessOverrideDimensions) {
200+
process.onProcessOverrideDimensions(event => this._onProcessOverrideDimensions.fire({ id, event }));
201+
}
202+
if (process.onProcessResolvedShellLaunchConfig) {
203+
process.onProcessResolvedShellLaunchConfig(event => this._onProcessResolvedShellLaunchConfig.fire({ id, event }));
204+
}
205+
if (process.onDidChangeHasChildProcesses) {
206+
process.onDidChangeHasChildProcesses(event => this._onProcessDidChangeHasChildProcesses.fire({ id, event }));
207+
}
186208
const processLaunchOptions: IPersistentTerminalProcessLaunchOptions = {
187209
env,
188210
executableEnv,
189211
windowsEnableConpty
190212
};
191213
const persistentProcess = new PersistentTerminalProcess(id, process, workspaceId, workspaceName, shouldPersist, cols, rows, processLaunchOptions, unicodeVersion, this._reconnectConstants, this._logService, isReviving ? shellLaunchConfig.initialText : undefined, shellLaunchConfig.icon, shellLaunchConfig.color, shellLaunchConfig.fixedDimensions);
192-
process.onDidChangeProperty(property => {
193-
if (property.type === ProcessPropertyType.Exit) {
194-
persistentProcess.dispose();
195-
this._ptys.delete(id);
196-
}
197-
this._onDidChangeProperty.fire({ id, property });
214+
process.onProcessExit(() => {
215+
persistentProcess.dispose();
216+
this._ptys.delete(id);
198217
});
218+
process.onDidChangeProperty(property => this._onDidChangeProperty.fire({ id, property }));
199219
persistentProcess.onProcessReplay(event => this._onProcessReplay.fire({ id, event }));
200220
persistentProcess.onProcessReady(event => this._onProcessReady.fire({ id, event }));
221+
persistentProcess.onProcessTitleChanged(event => this._onProcessTitleChanged.fire({ id, event }));
222+
persistentProcess.onProcessShellTypeChanged(event => this._onProcessShellTypeChanged.fire({ id, event }));
201223
persistentProcess.onProcessOrphanQuestion(() => this._onProcessOrphanQuestion.fire({ id }));
202224
persistentProcess.onDidChangeProperty(property => this._onDidChangeProperty.fire({ id, property }));
203225
this._ptys.set(id, persistentProcess);
@@ -406,6 +428,12 @@ export class PersistentTerminalProcess extends Disposable {
406428
readonly onProcessReplay = this._onProcessReplay.event;
407429
private readonly _onProcessReady = this._register(new Emitter<IProcessReadyEvent>());
408430
readonly onProcessReady = this._onProcessReady.event;
431+
private readonly _onProcessTitleChanged = this._register(new Emitter<string>());
432+
readonly onProcessTitleChanged = this._onProcessTitleChanged.event;
433+
private readonly _onProcessShellTypeChanged = this._register(new Emitter<TerminalShellType>());
434+
readonly onProcessShellTypeChanged = this._onProcessShellTypeChanged.event;
435+
private readonly _onProcessOverrideDimensions = this._register(new Emitter<ITerminalDimensionsOverride | undefined>());
436+
readonly onProcessOverrideDimensions = this._onProcessOverrideDimensions.event;
409437
private readonly _onProcessData = this._register(new Emitter<string>());
410438
readonly onProcessData = this._onProcessData.event;
411439
private readonly _onProcessOrphanQuestion = this._register(new Emitter<void>());
@@ -483,24 +511,20 @@ export class PersistentTerminalProcess extends Disposable {
483511
this._logService.info(`Persistent process "${this._persistentProcessId}": The short reconnection grace time of ${printTime(reconnectConstants.shortGraceTime)} has expired, shutting down pid ${this._pid}`);
484512
this.shutdown(true);
485513
}, reconnectConstants.shortGraceTime));
486-
this._register(this._terminalProcess.onDidChangeProperty(e => {
487-
if (e.type === ProcessPropertyType.Exit) {
488-
this._bufferer.stopBuffering(this._persistentProcessId);
489-
}
490-
this._onDidChangeProperty.fire(e);
491-
}));
514+
492515
this._register(this._terminalProcess.onProcessReady(e => {
493516
this._pid = e.pid;
494517
this._cwd = e.cwd;
495518
this._onProcessReady.fire(e);
496519
}));
497-
this._register(this._terminalProcess.onDidChangeProperty(e => {
498-
this._onDidChangeProperty.fire(e);
499-
}));
520+
this._register(this._terminalProcess.onProcessTitleChanged(e => this._onProcessTitleChanged.fire(e)));
521+
this._register(this._terminalProcess.onProcessShellTypeChanged(e => this._onProcessShellTypeChanged.fire(e)));
522+
this._register(this._terminalProcess.onDidChangeProperty(e => this._onDidChangeProperty.fire(e)));
500523

501524
// Data buffering to reduce the amount of messages going to the renderer
502525
this._bufferer = new TerminalDataBufferer((_, data) => this._onProcessData.fire(data));
503526
this._register(this._bufferer.startBuffering(this._persistentProcessId, this._terminalProcess.onProcessData));
527+
this._register(this._terminalProcess.onProcessExit(() => this._bufferer.stopBuffering(this._persistentProcessId)));
504528

505529
// Data recording for reconnect
506530
this._register(this.onProcessData(e => this._serializer.handleData(e)));
@@ -555,8 +579,8 @@ export class PersistentTerminalProcess extends Disposable {
555579
}
556580
} else {
557581
this._onProcessReady.fire({ pid: this._pid, cwd: this._cwd, capabilities: this._terminalProcess.capabilities, requiresWindowsMode: isWindows && getWindowsBuildNumber() < 21376 });
558-
this._onDidChangeProperty.fire({ type: ProcessPropertyType.Title, value: this._terminalProcess.currentTitle });
559-
this._onDidChangeProperty.fire({ type: ProcessPropertyType.ShellType, value: this._terminalProcess.shellType });
582+
this._onProcessTitleChanged.fire(this._terminalProcess.currentTitle);
583+
this._onProcessShellTypeChanged.fire(this._terminalProcess.shellType);
560584
this.triggerReplay();
561585
}
562586
return undefined;

0 commit comments

Comments
 (0)