diff --git a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts index 3c67ae5dfbc..68652895589 100644 --- a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts +++ b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts @@ -68,7 +68,7 @@ import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService' import { combinedAppender, ITelemetryAppender, NullAppender, NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender'; import { CustomEndpointTelemetryService } from 'vs/platform/telemetry/node/customEndpointTelemetryService'; -import { LocalReconnectConstants, TerminalIpcChannels } from 'vs/platform/terminal/common/terminal'; +import { LocalReconnectConstants, TerminalIpcChannels, TerminalSettingId } from 'vs/platform/terminal/common/terminal'; import { ILocalPtyService } from 'vs/platform/terminal/electron-sandbox/terminal'; import { PtyHostService } from 'vs/platform/terminal/node/ptyHostService'; import { ExtensionsStorageSyncService, IExtensionsStorageSyncService } from 'vs/platform/userDataSync/common/extensionsStorageSync'; @@ -276,8 +276,9 @@ class SharedProcessMain extends Disposable { ILocalPtyService, this._register( new PtyHostService({ - GraceTime: LocalReconnectConstants.GraceTime, - ShortGraceTime: LocalReconnectConstants.ShortGraceTime + graceTime: LocalReconnectConstants.GraceTime, + shortGraceTime: LocalReconnectConstants.ShortGraceTime, + scrollback: configurationService.getValue(TerminalSettingId.PersistentSessionScrollback) || 1 }, configurationService, logService, diff --git a/src/vs/platform/terminal/common/terminal.ts b/src/vs/platform/terminal/common/terminal.ts index dfaf5b5ffb4..f441105d7d4 100644 --- a/src/vs/platform/terminal/common/terminal.ts +++ b/src/vs/platform/terminal/common/terminal.ts @@ -89,6 +89,7 @@ export const enum TerminalSettingId { LocalEchoExcludePrograms = 'terminal.integrated.localEchoExcludePrograms', LocalEchoStyle = 'terminal.integrated.localEchoStyle', EnablePersistentSessions = 'terminal.integrated.enablePersistentSessions', + PersistentSessionScrollback = 'terminal.integrated.persistentSessionScrollback', InheritEnv = 'terminal.integrated.inheritEnv', ShowLinkHover = 'terminal.integrated.showLinkHover', } @@ -489,8 +490,9 @@ export interface ITerminalChildProcess { } export interface IReconnectConstants { - GraceTime: number, - ShortGraceTime: number + graceTime: number; + shortGraceTime: number; + scrollback: number; } export const enum LocalReconnectConstants { diff --git a/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts b/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts index fdadb9d1151..9e52532a20b 100644 --- a/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts +++ b/src/vs/platform/terminal/common/terminalPlatformConfiguration.ts @@ -360,6 +360,12 @@ const terminalPlatformConfiguration: IConfigurationNode = { type: 'boolean', default: true }, + [TerminalSettingId.PersistentSessionScrollback]: { + scope: ConfigurationScope.APPLICATION, + markdownDescription: localize('terminal.integrated.persistentSessionScrollback', "Controls the maximum amount of lines that will be restored when reconnecting to a persistent terminal session. Increasing this will restore more lines of scrollback at the cost of more memory and increase the time it takes to connect to terminals on start up. This setting requires a restart to take effect and should be set to a value less than or equal to `#terminal.integrated.scrollback#`."), + type: 'number', + default: 100 + }, [TerminalSettingId.ShowLinkHover]: { scope: ConfigurationScope.APPLICATION, description: localize('terminal.integrated.showLinkHover', "Whether to show hovers for links in the terminal output."), diff --git a/src/vs/platform/terminal/node/ptyHostMain.ts b/src/vs/platform/terminal/node/ptyHostMain.ts index fdc3ca40001..c8ea12f1e1f 100644 --- a/src/vs/platform/terminal/node/ptyHostMain.ts +++ b/src/vs/platform/terminal/node/ptyHostMain.ts @@ -7,7 +7,7 @@ import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc'; import { Server } from 'vs/base/parts/ipc/node/ipc.cp'; import { ConsoleLogger, LogService } from 'vs/platform/log/common/log'; import { LogLevelChannel } from 'vs/platform/log/common/logIpc'; -import { TerminalIpcChannels } from 'vs/platform/terminal/common/terminal'; +import { IReconnectConstants, TerminalIpcChannels } from 'vs/platform/terminal/common/terminal'; import { HeartbeatService } from 'vs/platform/terminal/node/heartbeatService'; import { PtyService } from 'vs/platform/terminal/node/ptyService'; @@ -23,9 +23,14 @@ server.registerChannel(TerminalIpcChannels.Log, logChannel); const heartbeatService = new HeartbeatService(); server.registerChannel(TerminalIpcChannels.Heartbeat, ProxyChannel.fromService(heartbeatService)); -const reconnectConstants = { GraceTime: parseInt(process.env.VSCODE_RECONNECT_GRACE_TIME || '0'), ShortGraceTime: parseInt(process.env.VSCODE_RECONNECT_SHORT_GRACE_TIME || '0') }; +const reconnectConstants: IReconnectConstants = { + graceTime: parseInt(process.env.VSCODE_RECONNECT_GRACE_TIME || '0'), + shortGraceTime: parseInt(process.env.VSCODE_RECONNECT_SHORT_GRACE_TIME || '0'), + scrollback: parseInt(process.env.VSCODE_RECONNECT_SCROLLBACK || '100'), +}; delete process.env.VSCODE_RECONNECT_GRACE_TIME; delete process.env.VSCODE_RECONNECT_SHORT_GRACE_TIME; +delete process.env.VSCODE_RECONNECT_SCROLLBACK; const ptyService = new PtyService(lastPtyId, logService, reconnectConstants); server.registerChannel(TerminalIpcChannels.PtyHost, ProxyChannel.fromService(ptyService)); diff --git a/src/vs/platform/terminal/node/ptyHostService.ts b/src/vs/platform/terminal/node/ptyHostService.ts index 1b326f3a066..b5a744c3990 100644 --- a/src/vs/platform/terminal/node/ptyHostService.ts +++ b/src/vs/platform/terminal/node/ptyHostService.ts @@ -117,8 +117,9 @@ export class PtyHostService extends Disposable implements IPtyService { VSCODE_AMD_ENTRYPOINT: 'vs/platform/terminal/node/ptyHostMain', VSCODE_PIPE_LOGGING: 'true', VSCODE_VERBOSE_LOGGING: 'true', // transmit console logs from server to client, - VSCODE_RECONNECT_GRACE_TIME: this._reconnectConstants.GraceTime, - VSCODE_RECONNECT_SHORT_GRACE_TIME: this._reconnectConstants.ShortGraceTime + VSCODE_RECONNECT_GRACE_TIME: this._reconnectConstants.graceTime, + VSCODE_RECONNECT_SHORT_GRACE_TIME: this._reconnectConstants.shortGraceTime, + VSCODE_RECONNECT_SCROLLBACK: this._reconnectConstants.scrollback } } ); diff --git a/src/vs/platform/terminal/node/ptyService.ts b/src/vs/platform/terminal/node/ptyService.ts index 16e82d34963..169add249d2 100644 --- a/src/vs/platform/terminal/node/ptyService.ts +++ b/src/vs/platform/terminal/node/ptyService.ts @@ -373,18 +373,22 @@ export class PersistentTerminalProcess extends Disposable { super(); this._logService.trace('persistentTerminalProcess#ctor', _persistentProcessId, arguments); - this._xterm = new Terminal({ cols, rows }); + this._xterm = new Terminal({ + cols, + rows, + scrollback: reconnectConstants.scrollback + }); this._recorder = new TerminalRecorder(cols, rows); this._orphanQuestionBarrier = null; this._orphanQuestionReplyTime = 0; this._disconnectRunner1 = this._register(new RunOnceScheduler(() => { - this._logService.info(`Persistent process "${this._persistentProcessId}": The reconnection grace time of ${printTime(reconnectConstants.GraceTime)} has expired, shutting down pid "${this._pid}"`); + this._logService.info(`Persistent process "${this._persistentProcessId}": The reconnection grace time of ${printTime(reconnectConstants.graceTime)} has expired, shutting down pid "${this._pid}"`); this.shutdown(true); - }, reconnectConstants.GraceTime)); + }, reconnectConstants.graceTime)); this._disconnectRunner2 = this._register(new RunOnceScheduler(() => { - this._logService.info(`Persistent process "${this._persistentProcessId}": The short reconnection grace time of ${printTime(reconnectConstants.ShortGraceTime)} has expired, shutting down pid ${this._pid}`); + this._logService.info(`Persistent process "${this._persistentProcessId}": The short reconnection grace time of ${printTime(reconnectConstants.shortGraceTime)} has expired, shutting down pid ${this._pid}`); this.shutdown(true); - }, reconnectConstants.ShortGraceTime)); + }, reconnectConstants.shortGraceTime)); this._register(this._terminalProcess.onProcessReady(e => { this._pid = e.pid; @@ -490,7 +494,7 @@ export class PersistentTerminalProcess extends Disposable { } const serialize = new SerializeAddon(); this._xterm.loadAddon(serialize); - const serialized = serialize.serialize(100); + const serialized = serialize.serialize(this._xterm.getOption('scrollback')); this._logService.info('serialized', serialized); // this._onProcessReplay.fire(ev); this._onProcessReplay.fire({