Skip to content

Commit ce3f06b

Browse files
committed
Bring local terminal reconnect changes to remote
Part of microsoft#187076
1 parent ad17b84 commit ce3f06b

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

src/vs/workbench/contrib/terminal/browser/remoteTerminalBackend.ts

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { DeferredPromise } from 'vs/base/common/async';
77
import { Emitter } from 'vs/base/common/event';
88
import { revive } from 'vs/base/common/marshalling';
9-
import { PerformanceMark } from 'vs/base/common/performance';
9+
import { PerformanceMark, mark } from 'vs/base/common/performance';
1010
import { IProcessEnvironment, OperatingSystem } from 'vs/base/common/platform';
1111
import { ICommandService } from 'vs/platform/commands/common/commands';
1212
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -324,22 +324,28 @@ class RemoteTerminalBackend extends BaseTerminalBackend implements ITerminalBack
324324
// Revive processes if needed
325325
const serializedState = this._storageService.get(TerminalStorageKeys.TerminalBufferState, StorageScope.WORKSPACE);
326326
const parsed = this._deserializeTerminalState(serializedState);
327-
if (parsed) {
328-
try {
329-
// Note that remote terminals do not get their environment re-resolved unlike in local terminals
330-
331-
await this._remoteTerminalChannel.reviveTerminalProcesses(parsed, Intl.DateTimeFormat().resolvedOptions().locale);
332-
this._storageService.remove(TerminalStorageKeys.TerminalBufferState, StorageScope.WORKSPACE);
333-
// If reviving processes, send the terminal layout info back to the pty host as it
334-
// will not have been persisted on application exit
335-
const layoutInfo = this._storageService.get(TerminalStorageKeys.TerminalLayoutInfo, StorageScope.WORKSPACE);
336-
if (layoutInfo) {
337-
await this._remoteTerminalChannel.setTerminalLayoutInfo(JSON.parse(layoutInfo));
338-
this._storageService.remove(TerminalStorageKeys.TerminalLayoutInfo, StorageScope.WORKSPACE);
339-
}
340-
} catch {
341-
// no-op
327+
if (!parsed) {
328+
return undefined;
329+
}
330+
331+
try {
332+
// Note that remote terminals do not get their environment re-resolved unlike in local terminals
333+
334+
mark('code/terminal/willReviveTerminalProcessesRemote');
335+
await this._remoteTerminalChannel.reviveTerminalProcesses(parsed, Intl.DateTimeFormat().resolvedOptions().locale);
336+
mark('code/terminal/didReviveTerminalProcessesRemote');
337+
this._storageService.remove(TerminalStorageKeys.TerminalBufferState, StorageScope.WORKSPACE);
338+
// If reviving processes, send the terminal layout info back to the pty host as it
339+
// will not have been persisted on application exit
340+
const layoutInfo = this._storageService.get(TerminalStorageKeys.TerminalLayoutInfo, StorageScope.WORKSPACE);
341+
if (layoutInfo) {
342+
mark('code/terminal/willSetTerminalLayoutInfoRemote');
343+
await this._remoteTerminalChannel.setTerminalLayoutInfo(JSON.parse(layoutInfo));
344+
mark('code/terminal/didSetTerminalLayoutInfoRemote');
345+
this._storageService.remove(TerminalStorageKeys.TerminalLayoutInfo, StorageScope.WORKSPACE);
342346
}
347+
} catch (e: unknown) {
348+
this._logService.warn('RemoteTerminalBackend#getTerminalLayoutInfo Error', e && typeof e === 'object' && 'message' in e ? e.message : e);
343349
}
344350

345351
return this._remoteTerminalChannel.getTerminalLayoutInfo();

0 commit comments

Comments
 (0)