Remove now unneeded optional checks

This commit is contained in:
Daniel Imms 2023-07-06 11:42:22 -07:00
parent ed59e75f3d
commit 074121ee30
No known key found for this signature in database
GPG key ID: E5CF412B63651C69
2 changed files with 58 additions and 68 deletions

View file

@ -107,7 +107,7 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
async call(ctx: RemoteAgentConnectionContext, command: string, args?: any): Promise<any> {
switch (command) {
case '$restartPtyHost': return this._ptyHostService.restartPtyHost?.apply(this._ptyHostService, args);
case '$restartPtyHost': return this._ptyHostService.restartPtyHost.apply(this._ptyHostService, args);
case '$createProcess': {
const uriTransformer = createURITransformer(ctx.remoteAuthority);
@ -119,7 +119,7 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
case '$listProcesses': return this._ptyHostService.listProcesses.apply(this._ptyHostService, args);
case '$getPerformanceMarks': return this._ptyHostService.getPerformanceMarks.apply(this._ptyHostService, args);
case '$orphanQuestionReply': return this._ptyHostService.orphanQuestionReply.apply(this._ptyHostService, args);
case '$acceptPtyHostResolvedVariables': return this._ptyHostService.acceptPtyHostResolvedVariables?.apply(this._ptyHostService, args);
case '$acceptPtyHostResolvedVariables': return this._ptyHostService.acceptPtyHostResolvedVariables.apply(this._ptyHostService, args);
case '$start': return this._ptyHostService.start.apply(this._ptyHostService, args);
case '$input': return this._ptyHostService.input.apply(this._ptyHostService, args);
@ -152,7 +152,7 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
case '$refreshProperty': return this._ptyHostService.refreshProperty.apply(this._ptyHostService, args);
case '$requestDetachInstance': return this._ptyHostService.requestDetachInstance(args[0], args[1]);
case '$acceptDetachedInstance': return this._ptyHostService.acceptDetachInstanceReply(args[0], args[1]);
case '$freePortKillProcess': return this._ptyHostService.freePortKillProcess?.apply(this._ptyHostService, args);
case '$freePortKillProcess': return this._ptyHostService.freePortKillProcess.apply(this._ptyHostService, args);
}
throw new Error(`IPC Command ${command} not found`);
@ -320,7 +320,7 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
}
private async _getProfiles(workspaceId: string, profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]> {
return this._ptyHostService.getProfiles?.(workspaceId, profiles, defaultProfile, includeDetectedProfiles) || [];
return this._ptyHostService.getProfiles(workspaceId, profiles, defaultProfile, includeDetectedProfiles) || [];
}
private _getEnvironment(): platform.IProcessEnvironment {

View file

@ -46,12 +46,9 @@ export abstract class BaseTerminalBackend extends Disposable {
let hasStarted = false;
// Attach pty host listeners
if (this._ptyHostController.onPtyHostExit) {
this._register(this._ptyHostController.onPtyHostExit(() => {
this._logService.error(`The terminal's pty host process exited, the connection to all terminal processes was lost`);
}));
}
if (this._ptyHostController.onPtyHostStart) {
this.onPtyHostConnected(() => hasStarted = true);
this._register(this._ptyHostController.onPtyHostStart(() => {
this._logService.debug(`The terminal's pty host process is starting`);
@ -63,8 +60,6 @@ export abstract class BaseTerminalBackend extends Disposable {
statusBarAccessor?.dispose();
this._isPtyHostUnresponsive = false;
}));
}
if (this._ptyHostController.onPtyHostUnresponsive) {
this._register(this._ptyHostController.onPtyHostUnresponsive(() => {
statusBarAccessor?.dispose();
if (!unresponsiveStatusBarEntry) {
@ -82,8 +77,6 @@ export abstract class BaseTerminalBackend extends Disposable {
this._isPtyHostUnresponsive = true;
this._onPtyHostUnresponsive.fire();
}));
}
if (this._ptyHostController.onPtyHostResponsive) {
this._register(this._ptyHostController.onPtyHostResponsive(() => {
if (!this._isPtyHostUnresponsive) {
return;
@ -93,8 +86,6 @@ export abstract class BaseTerminalBackend extends Disposable {
this._isPtyHostUnresponsive = false;
this._onPtyHostResponsive.fire();
}));
}
if (this._ptyHostController.onPtyHostRequestResolveVariables) {
this._register(this._ptyHostController.onPtyHostRequestResolveVariables(async e => {
// Only answer requests for this workspace
if (e.workspaceId !== this._workspaceContextService.getWorkspace().id) {
@ -106,13 +97,12 @@ export abstract class BaseTerminalBackend extends Disposable {
return configurationResolverService.resolveAsync(lastActiveWorkspaceRoot, t);
});
const result = await Promise.all(resolveCalls);
this._ptyHostController.acceptPtyHostResolvedVariables?.(e.requestId, result);
this._ptyHostController.acceptPtyHostResolvedVariables(e.requestId, result);
}));
}
}
restartPtyHost(): void {
this._ptyHostController.restartPtyHost?.();
this._ptyHostController.restartPtyHost();
}
protected _deserializeTerminalState(serializedState: string | undefined): ISerializedTerminalState[] | undefined {