From af174933d6718d051622a5153e24806242c62d3d Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Sun, 15 Aug 2021 19:58:28 +0200 Subject: [PATCH] telnet: fixed size negotiation order --- tabby-telnet/src/session.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tabby-telnet/src/session.ts b/tabby-telnet/src/session.ts index f83fbf9f..d44ad7ed 100644 --- a/tabby-telnet/src/session.ts +++ b/tabby-telnet/src/session.ts @@ -170,7 +170,7 @@ export class TelnetSession extends BaseSession { } if (command === TelnetCommands.DO) { if (option === TelnetOptions.NEGO_WINDOW_SIZE) { - this.resize(0, 0) + this.emitSize() } else if (option === TelnetOptions.ECHO) { this.echoEnabled = true this.emitTelnet(TelnetCommands.WILL, option) @@ -210,10 +210,18 @@ export class TelnetSession extends BaseSession { this.lastHeight = h } if (this.lastWidth && this.lastHeight && this.telnetProtocol) { + this.emitSize() + } + } + + private emitSize () { + if (this.lastWidth && this.lastHeight) { this.emitTelnetSuboption(TelnetOptions.NEGO_WINDOW_SIZE, Buffer.from([ this.lastWidth >> 8, this.lastWidth & 0xff, this.lastHeight >> 8, this.lastHeight & 0xff, ])) + } else { + this.emitTelnet(TelnetCommands.WONT, TelnetOptions.NEGO_WINDOW_SIZE) } } -- GitLab