From eaa0d2f4d3b124023f90d7f76e4cbb7d69dae77d Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 29 May 2021 10:05:55 -0700 Subject: [PATCH] ssh: fix lost character after keyboard auth on windows closes: https://github.com/wez/wezterm/issues/771 --- docs/changelog.md | 1 + mux/src/ssh.rs | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index ca96b632a..1ee37208a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -28,6 +28,7 @@ As features stabilize some brief notes about them will accumulate here. * New: bold and/or italics are now synthesized for fonts when the matching font is not actually italic or doesn't match the requested weight. [#815](https://github.com/wez/wezterm/issues/815) * Updated: conpty.dll to v1.9.1445.0; fixes color bar artifacts when resizing window and allows win32 console applications to use mouse events * Fixed: Windows: pane could linger after the process has died, closing only when a new pane/tab event occurs +* Fixed: Windows: first character after `wezterm ssh` keyboard authention was swallowed [#771](https://github.com/wez/wezterm/issues/771) ### 20210502-154244-3f7122cb diff --git a/mux/src/ssh.rs b/mux/src/ssh.rs index de2882421..754bb1610 100644 --- a/mux/src/ssh.rs +++ b/mux/src/ssh.rs @@ -877,16 +877,15 @@ impl portable_pty::MasterPty for WrappedSshPty { impl std::io::Write for PtyWriter { fn write(&mut self, buf: &[u8]) -> std::io::Result { - match self.writer.write(buf) { - Ok(len) if len > 0 => Ok(len), - res => match self.rx.recv() { - Ok(writer) => { - self.writer = writer; - self.writer.write(buf) - } - _ => res, - }, + // Check for a new writer first: on Windows, the socket + // will let us successfully write a byte to a disconnected + // socket and we won't discover the issue until we write + // the next byte. + // + if let Ok(writer) = self.rx.try_recv() { + self.writer = writer; } + self.writer.write(buf) } fn flush(&mut self) -> std::io::Result<()> {