Skip to content

Commit

Permalink
fix #133741 (#136763)
Browse files Browse the repository at this point in the history
  • Loading branch information
meganrogge committed Nov 9, 2021
1 parent d5d87b8 commit 5fa4c88
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 30 deletions.
13 changes: 3 additions & 10 deletions src/vs/server/remoteTerminalChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IServerChannel } from 'vs/base/parts/ipc/common/ipc';
import { createRandomIPCHandle } from 'vs/base/parts/ipc/node/ipc.net';
import { ILogService } from 'vs/platform/log/common/log';
import { RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { IPtyService, IShellLaunchConfig, ITerminalProfile, ITerminalsLayoutInfo } from 'vs/platform/terminal/common/terminal';
import { IPtyService, IShellLaunchConfig, ITerminalProfile } from 'vs/platform/terminal/common/terminal';
import { IGetTerminalLayoutInfoArgs, ISetTerminalLayoutInfoArgs } from 'vs/platform/terminal/common/terminalProcess';
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { createRemoteURITransformer } from 'vs/server/remoteUriTransformer';
Expand Down Expand Up @@ -124,8 +124,8 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
case '$getProfiles': return this._getProfiles.apply(this, args);
case '$getEnvironment': return this._getEnvironment();
case '$getWslPath': return this._getWslPath(args[0]);
case '$getTerminalLayoutInfo': return this._getTerminalLayoutInfo(<IGetTerminalLayoutInfoArgs>args);
case '$setTerminalLayoutInfo': return this._setTerminalLayoutInfo(<ISetTerminalLayoutInfoArgs>args);
case '$getTerminalLayoutInfo': return this._ptyService.getTerminalLayoutInfo(<IGetTerminalLayoutInfoArgs>args);
case '$setTerminalLayoutInfo': return this._ptyService.setTerminalLayoutInfo(<ISetTerminalLayoutInfoArgs>args);
case '$serializeTerminalState': return this._ptyService.serializeTerminalState.apply(this._ptyService, args);
case '$reviveTerminalProcesses': return this._ptyService.reviveTerminalProcesses.apply(this._ptyService, args);
case '$setUnicodeVersion': return this._ptyService.setUnicodeVersion.apply(this._ptyService, args);
Expand Down Expand Up @@ -315,13 +315,6 @@ export class RemoteTerminalChannel extends Disposable implements IServerChannel<
return this._ptyService.getWslPath(original);
}

private _setTerminalLayoutInfo(args: ISetTerminalLayoutInfoArgs): void {
this._ptyService.setTerminalLayoutInfo(args);
}

private async _getTerminalLayoutInfo(args: IGetTerminalLayoutInfoArgs): Promise<ITerminalsLayoutInfo | undefined> {
return this._ptyService.getTerminalLayoutInfo(args);
}

private _reduceConnectionGraceTime(): Promise<void> {
return this._ptyService.reduceConnectionGraceTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class RemoteTerminalBackend extends Disposable implements ITerminalBackend {
return this._remoteTerminalChannel?.getWslPath(original) || original;
}

setTerminalLayoutInfo(layout: ITerminalsLayoutInfoById): Promise<void> {
async setTerminalLayoutInfo(layout?: ITerminalsLayoutInfoById): Promise<void> {
if (!this._remoteTerminalChannel) {
throw new Error(`Cannot call setActiveInstanceId when there is no remote`);
}
Expand Down
34 changes: 17 additions & 17 deletions src/vs/workbench/contrib/terminal/browser/terminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class TerminalService implements ITerminalService {
private _configHelper: TerminalConfigHelper;
private _remoteTerminalsInitPromise: Promise<void> | undefined;
private _localTerminalsInitPromise: Promise<void> | undefined;
private _connectionState: TerminalConnectionState;
private _connectionState: TerminalConnectionState = TerminalConnectionState.Connecting;
private _nativeDelegate?: ITerminalServiceNativeDelegate;
private _shutdownWindowCount?: number;

Expand Down Expand Up @@ -236,29 +236,29 @@ export class TerminalService implements ITerminalService {
}
});

const enableTerminalReconnection = this.configHelper.config.enablePersistentSessions;

// Connect to the extension host if it's there, set the connection state to connected when
// it's done. This should happen even when there is no extension host.
this._connectionState = TerminalConnectionState.Connecting;

const isPersistentRemote = !!this._environmentService.remoteAuthority && enableTerminalReconnection;

if (isPersistentRemote) {
this._remoteTerminalsInitPromise = this._reconnectToRemoteTerminals();
} else if (enableTerminalReconnection) {
this._localTerminalsInitPromise = this._reconnectToLocalTerminals();
} else {
this._connectionState = TerminalConnectionState.Connected;
}

// Create async as the class depends on `this`
timeout(0).then(() => this._instantiationService.createInstance(TerminalEditorStyle, document.head));
}

handleNewRegisteredBackend(backend: ITerminalBackend) {
if (backend.remoteAuthority === this._environmentService.remoteAuthority) {
this._primaryBackend = backend;
const enableTerminalReconnection = this.configHelper.config.enablePersistentSessions;

// Connect to the extension host if it's there, set the connection state to connected when
// it's done. This should happen even when there is no extension host.
this._connectionState = TerminalConnectionState.Connecting;

const isPersistentRemote = !!this._environmentService.remoteAuthority && enableTerminalReconnection;

if (isPersistentRemote) {
this._remoteTerminalsInitPromise = this._reconnectToRemoteTerminals();
} else if (enableTerminalReconnection) {
this._localTerminalsInitPromise = this._reconnectToLocalTerminals();
} else {
this._connectionState = TerminalConnectionState.Connected;
}

backend.onDidRequestDetach(async (e) => {
const instanceToDetach = this.getInstanceFromResource(getTerminalUri(e.workspaceId, e.instanceId));
if (instanceToDetach) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ export class RemoteTerminalChannelClient {
return this._channel.call('$getWslPath', [original]);
}

setTerminalLayoutInfo(layout: ITerminalsLayoutInfoById): Promise<void> {
setTerminalLayoutInfo(layout?: ITerminalsLayoutInfoById): Promise<void> {
const workspace = this._workspaceContextService.getWorkspace();
const args: ISetTerminalLayoutInfoArgs = {
workspaceId: workspace.id,
tabs: layout.tabs
tabs: layout ? layout.tabs : []
};
return this._channel.call<void>('$setTerminalLayoutInfo', args);
}
Expand Down

0 comments on commit 5fa4c88

Please sign in to comment.