From 5087e7de255aab9ea4f6bff367bb191e85697bde Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 15 Jun 2022 20:01:53 +0200 Subject: [PATCH] optimized flow control --- tabby-terminal/src/frontends/xtermFrontend.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tabby-terminal/src/frontends/xtermFrontend.ts b/tabby-terminal/src/frontends/xtermFrontend.ts index 5a577ddf..29c17e4d 100644 --- a/tabby-terminal/src/frontends/xtermFrontend.ts +++ b/tabby-terminal/src/frontends/xtermFrontend.ts @@ -39,13 +39,14 @@ class FlowControl { this.bytesWritten += data.length if (this.bytesWritten > this.bytesThreshold) { this.pendingCallbacks++ - if (this.pendingCallbacks > this.highWatermark) { + this.bytesWritten = 0 + if (!this.blocked && this.pendingCallbacks > this.highWatermark) { this.blocked = true this.blocked$.next(true) } this.xterm.write(data, () => { this.pendingCallbacks-- - if (this.pendingCallbacks < this.lowWatermark) { + if (this.blocked && this.pendingCallbacks < this.lowWatermark) { this.blocked = false this.blocked$.next(false) }