Skip to content

Commit a445588

Browse files
code-asherAkash Satheesan
authored andcommitted
Use service in terminal channel instead of interface
This allows us to avoid checking whether some functions exist when we know they will. This means we can't use this for other pty services like the browser one but that won't be necessary as this strictly runs on the Node end anyway.
1 parent d8a1f7d commit a445588

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

lib/vscode/src/vs/server/channel.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ILogService } from 'vs/platform/log/common/log';
2020
import product from 'vs/platform/product/common/product';
2121
import { IRemoteAgentEnvironment, RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
2222
import { ITelemetryData, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
23-
import { IPtyService, IShellLaunchConfig, ITerminalEnvironment } from 'vs/platform/terminal/common/terminal';
23+
import { IShellLaunchConfig, ITerminalEnvironment } from 'vs/platform/terminal/common/terminal';
2424
import { getTranslations } from 'vs/server/nls';
2525
import { getUriTransformer } from 'vs/server/util';
2626
import { IFileChangeDto } from 'vs/workbench/api/common/extHost.protocol';
@@ -31,6 +31,7 @@ import * as terminal from 'vs/workbench/contrib/terminal/common/remoteTerminalCh
3131
import * as terminalEnvironment from 'vs/workbench/contrib/terminal/common/terminalEnvironment';
3232
import { AbstractVariableResolverService } from 'vs/workbench/services/configurationResolver/common/variableResolver';
3333
import { ExtensionScanner, ExtensionScannerInput } from 'vs/workbench/services/extensions/node/extensionPoints';
34+
import { PtyHostService } from 'vs/platform/terminal/node/ptyHostService';
3435

3536
/**
3637
* Extend the file provider to allow unwatching.
@@ -386,7 +387,7 @@ class VariableResolverService extends AbstractVariableResolverService {
386387
export class TerminalProviderChannel implements IServerChannel<RemoteAgentConnectionContext>, IDisposable {
387388
public constructor (
388389
private readonly logService: ILogService,
389-
private readonly ptyService: IPtyService,
390+
private readonly ptyService: PtyHostService,
390391
) {}
391392

392393
public listen(_: RemoteAgentConnectionContext, event: string, args: any): Event<any> {
@@ -397,7 +398,7 @@ export class TerminalProviderChannel implements IServerChannel<RemoteAgentConnec
397398
case '$onPtyHostStartEvent': return this.ptyService.onPtyHostStart || Event.None;
398399
case '$onPtyHostUnresponsiveEvent': return this.ptyService.onPtyHostUnresponsive || Event.None;
399400
case '$onPtyHostResponsiveEvent': return this.ptyService.onPtyHostResponsive || Event.None;
400-
case '$onPtyHostRequestResolveVariablesEvent': return this.ptyService.onPtyHostRequestResolveVariables || Event.None;
401+
case '$onPtyHostRequestResolveVariablesEvent': return this.ptyService.onPtyHostRequestResolveVariables || Event.None;
401402
case '$onProcessDataEvent': return this.ptyService.onProcessData;
402403
case '$onProcessExitEvent': return this.ptyService.onProcessExit;
403404
case '$onProcessReadyEvent': return this.ptyService.onProcessReady;
@@ -411,6 +412,8 @@ export class TerminalProviderChannel implements IServerChannel<RemoteAgentConnec
411412
// commands on the terminal that will do things in VS Code but we
412413
// already have that functionality via a socket so I'm not sure what
413414
// this is for.
415+
// NOTE: VSCODE_IPC_HOOK_CLI is now missing, perhaps this is meant to
416+
// replace that in some way.
414417
case '$onExecuteCommand': return Event.None;
415418
}
416419

@@ -421,7 +424,7 @@ export class TerminalProviderChannel implements IServerChannel<RemoteAgentConnec
421424
logger.trace('TerminalProviderChannel:call', field('command', command), field('args', args));
422425

423426
switch (command) {
424-
case '$restartPtyHost': return this.restartPtyHost();
427+
case '$restartPtyHost': return this.ptyService.restartPtyHost();
425428
case '$createProcess': return this.createProcess(context.remoteAuthority, args);
426429
case '$attachToProcess': return this.ptyService.attachToProcess(args[0]);
427430
case '$start': return this.ptyService.start(args[0]);
@@ -440,8 +443,8 @@ export class TerminalProviderChannel implements IServerChannel<RemoteAgentConnec
440443
case '$getDefaultSystemShell': return this.ptyService.getDefaultSystemShell(args[0]);
441444
case '$reduceConnectionGraceTime': return this.ptyService.reduceConnectionGraceTime();
442445
case '$updateTitle': return this.ptyService.updateTitle(args[0], args[1], args[2]);
443-
case '$getProfiles': return this.ptyService.getProfiles!(args[0], args[1], args[2]);
444-
case '$acceptPtyHostResolvedVariables': return this.ptyService.acceptPtyHostResolvedVariables!(args[0], args[1]);
446+
case '$getProfiles': return this.ptyService.getProfiles(args[0], args[1], args[2]);
447+
case '$acceptPtyHostResolvedVariables': return this.ptyService.acceptPtyHostResolvedVariables(args[0], args[1]);
445448
}
446449

447450
throw new Error(`Invalid call '${command}'`);
@@ -451,13 +454,6 @@ export class TerminalProviderChannel implements IServerChannel<RemoteAgentConnec
451454
// Nothing at the moment.
452455
}
453456

454-
private async restartPtyHost(): Promise<void> {
455-
if (this.ptyService.restartPtyHost) {
456-
return this.ptyService.restartPtyHost();
457-
}
458-
}
459-
460-
461457
// References: - ../../workbench/api/node/extHostTerminalService.ts
462458
// - ../../workbench/contrib/terminal/browser/terminalProcessManager.ts
463459
private async createProcess(remoteAuthority: string, args: terminal.ICreateTerminalProcessArguments): Promise<terminal.ICreateTerminalProcessResult> {

0 commit comments

Comments
 (0)