Only replay terminals when detached

This commit is contained in:
Asher 2020-11-19 10:58:04 -06:00
parent 8311cf5657
commit 182aca6490
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -1466,10 +1466,10 @@ index 0000000000000000000000000000000000000000..6ce56bec114a6d8daf5dd3ded945ea78
+}
diff --git a/src/vs/server/node/channel.ts b/src/vs/server/node/channel.ts
new file mode 100644
index 0000000000000000000000000000000000000000..cb3a45fda10a6bcbff73275b5734641b3319cc9b
index 0000000000000000000000000000000000000000..b65bf283739a2b05c82fe38a038d2a10957c0d40
--- /dev/null
+++ b/src/vs/server/node/channel.ts
@@ -0,0 +1,828 @@
@@ -0,0 +1,848 @@
+import { field, logger } from '@coder/logger';
+import { Server } from '@coder/node-browser';
+import * as os from 'os';
@ -1893,6 +1893,7 @@ index 0000000000000000000000000000000000000000..cb3a45fda10a6bcbff73275b5734641b
+ private readonly maxReplayData = 10000;
+ private totalReplayData = 0;
+
+ private detached = false;
+ private buffering = false;
+ private readonly _onEvent = new Emitter<terminal.IRemoteTerminalProcessEvent>({
+ // Don't bind to data until something is listening.
@ -1906,10 +1907,11 @@ index 0000000000000000000000000000000000000000..cb3a45fda10a6bcbff73275b5734641b
+
+ // Replay stored events.
+ onFirstListenerDidAdd: () => {
+ if (this.replayData.length === 0) {
+ if (!this.detached) {
+ return;
+ }
+
+ this.detached = false;
+ logger.debug('Terminal replaying', field('id', this.id));
+ this._onEvent.fire({
+ type: 'replay',
@ -1922,6 +1924,7 @@ index 0000000000000000000000000000000000000000..cb3a45fda10a6bcbff73275b5734641b
+ },
+
+ onLastListenerRemove: () => {
+ this.detached = true;
+ logger.debug('Terminal unbound', field('id', this.id));
+ if (!this.persist) { // Used by debug consoles.
+ this.dispose();