Skip to content
This repository was archived by the owner on Dec 21, 2022. It is now read-only.

Commit 0b7df9a

Browse files
Read as much as possible from stdin each time.
(Fixes bug for some applications that rely on keys that send multiple bytes to receive it at once.)
1 parent 10275b2 commit 0b7df9a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

deployer/run/socket_client.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,19 @@ def _read_loop(self):
240240
# Non blocking read. (Write works better in blocking mode.
241241
# Especially on OS X.)
242242
fdesc.setNonBlocking(sys.stdin)
243-
data = sys.stdin.read(1)
243+
data = sys.stdin.read(1024)
244+
# We read larger chuncks (more than just one byte) in
245+
# one go. This is important for meta and arrow keys
246+
# which consist of multiple bytes. Many applications
247+
# rely on this that they'll receive them together.
244248
fdesc.setBlocking(sys.stdin)
245249

246250
# If we're finish and 'wait_for_closing' was set. Any key
247251
# press will terminate the client.
248252
if self.wait_for_closing:
249253
break
250254

251-
if ord(data) == 14: # Ctrl-N
255+
if chr(14) in data: # Ctrl-N
252256
# Tell the server to open a new window.
253257
self.socket.sendall(pickle.dumps(('open-new-window', '')))
254258
else:

0 commit comments

Comments
 (0)