mirror of
https://github.com/Microsoft/vscode
synced 2024-10-02 17:32:41 +00:00
Remove now unneeded optional checks
This commit is contained in:
parent
ed59e75f3d
commit
074121ee30
|
@ -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 {
|
||||
|
|
|
@ -46,73 +46,63 @@ 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`);
|
||||
// Only fire the _restart_ event after it has started
|
||||
if (hasStarted) {
|
||||
this._logService.trace('IPtyHostController#onPtyHostRestart');
|
||||
this._onPtyHostRestart.fire();
|
||||
}
|
||||
statusBarAccessor?.dispose();
|
||||
this._isPtyHostUnresponsive = false;
|
||||
}));
|
||||
}
|
||||
if (this._ptyHostController.onPtyHostUnresponsive) {
|
||||
this._register(this._ptyHostController.onPtyHostUnresponsive(() => {
|
||||
statusBarAccessor?.dispose();
|
||||
if (!unresponsiveStatusBarEntry) {
|
||||
unresponsiveStatusBarEntry = {
|
||||
name: localize('ptyHostStatus', 'Pty Host Status'),
|
||||
text: `$(debug-disconnect) ${localize('ptyHostStatus.short', 'Pty Host')}`,
|
||||
tooltip: localize('nonResponsivePtyHost', "The connection to the terminal's pty host process is unresponsive, terminals may stop working. Click to manually restart the pty host."),
|
||||
ariaLabel: localize('ptyHostStatus.ariaLabel', 'Pty Host is unresponsive'),
|
||||
command: TerminalCommandId.RestartPtyHost,
|
||||
backgroundColor: themeColorFromId(STATUS_BAR_WARNING_ITEM_BACKGROUND),
|
||||
color: themeColorFromId(STATUS_BAR_WARNING_ITEM_FOREGROUND),
|
||||
};
|
||||
}
|
||||
statusBarAccessor = statusBarService.addEntry(unresponsiveStatusBarEntry, 'ptyHostStatus', StatusbarAlignment.LEFT);
|
||||
this._isPtyHostUnresponsive = true;
|
||||
this._onPtyHostUnresponsive.fire();
|
||||
}));
|
||||
}
|
||||
if (this._ptyHostController.onPtyHostResponsive) {
|
||||
this._register(this._ptyHostController.onPtyHostResponsive(() => {
|
||||
if (!this._isPtyHostUnresponsive) {
|
||||
return;
|
||||
}
|
||||
this._logService.info('The pty host became responsive again');
|
||||
statusBarAccessor?.dispose();
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file);
|
||||
const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined;
|
||||
const resolveCalls: Promise<string>[] = e.originalText.map(t => {
|
||||
return configurationResolverService.resolveAsync(lastActiveWorkspaceRoot, t);
|
||||
});
|
||||
const result = await Promise.all(resolveCalls);
|
||||
this._ptyHostController.acceptPtyHostResolvedVariables?.(e.requestId, result);
|
||||
}));
|
||||
}
|
||||
this._register(this._ptyHostController.onPtyHostExit(() => {
|
||||
this._logService.error(`The terminal's pty host process exited, the connection to all terminal processes was lost`);
|
||||
}));
|
||||
this.onPtyHostConnected(() => hasStarted = true);
|
||||
this._register(this._ptyHostController.onPtyHostStart(() => {
|
||||
this._logService.debug(`The terminal's pty host process is starting`);
|
||||
// Only fire the _restart_ event after it has started
|
||||
if (hasStarted) {
|
||||
this._logService.trace('IPtyHostController#onPtyHostRestart');
|
||||
this._onPtyHostRestart.fire();
|
||||
}
|
||||
statusBarAccessor?.dispose();
|
||||
this._isPtyHostUnresponsive = false;
|
||||
}));
|
||||
this._register(this._ptyHostController.onPtyHostUnresponsive(() => {
|
||||
statusBarAccessor?.dispose();
|
||||
if (!unresponsiveStatusBarEntry) {
|
||||
unresponsiveStatusBarEntry = {
|
||||
name: localize('ptyHostStatus', 'Pty Host Status'),
|
||||
text: `$(debug-disconnect) ${localize('ptyHostStatus.short', 'Pty Host')}`,
|
||||
tooltip: localize('nonResponsivePtyHost', "The connection to the terminal's pty host process is unresponsive, terminals may stop working. Click to manually restart the pty host."),
|
||||
ariaLabel: localize('ptyHostStatus.ariaLabel', 'Pty Host is unresponsive'),
|
||||
command: TerminalCommandId.RestartPtyHost,
|
||||
backgroundColor: themeColorFromId(STATUS_BAR_WARNING_ITEM_BACKGROUND),
|
||||
color: themeColorFromId(STATUS_BAR_WARNING_ITEM_FOREGROUND),
|
||||
};
|
||||
}
|
||||
statusBarAccessor = statusBarService.addEntry(unresponsiveStatusBarEntry, 'ptyHostStatus', StatusbarAlignment.LEFT);
|
||||
this._isPtyHostUnresponsive = true;
|
||||
this._onPtyHostUnresponsive.fire();
|
||||
}));
|
||||
this._register(this._ptyHostController.onPtyHostResponsive(() => {
|
||||
if (!this._isPtyHostUnresponsive) {
|
||||
return;
|
||||
}
|
||||
this._logService.info('The pty host became responsive again');
|
||||
statusBarAccessor?.dispose();
|
||||
this._isPtyHostUnresponsive = false;
|
||||
this._onPtyHostResponsive.fire();
|
||||
}));
|
||||
this._register(this._ptyHostController.onPtyHostRequestResolveVariables(async e => {
|
||||
// Only answer requests for this workspace
|
||||
if (e.workspaceId !== this._workspaceContextService.getWorkspace().id) {
|
||||
return;
|
||||
}
|
||||
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file);
|
||||
const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined;
|
||||
const resolveCalls: Promise<string>[] = e.originalText.map(t => {
|
||||
return configurationResolverService.resolveAsync(lastActiveWorkspaceRoot, t);
|
||||
});
|
||||
const result = await Promise.all(resolveCalls);
|
||||
this._ptyHostController.acceptPtyHostResolvedVariables(e.requestId, result);
|
||||
}));
|
||||
}
|
||||
|
||||
restartPtyHost(): void {
|
||||
this._ptyHostController.restartPtyHost?.();
|
||||
this._ptyHostController.restartPtyHost();
|
||||
}
|
||||
|
||||
protected _deserializeTerminalState(serializedState: string | undefined): ISerializedTerminalState[] | undefined {
|
||||
|
|
Loading…
Reference in a new issue