Fix cf arrow key handling - remove broken select() logic

The select() timeout approach was causing arrow keys to be
misinterpreted as Escape. Revert to direct reading since escape
sequence bytes arrive together from the terminal.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
rob
2026-01-18 04:52:47 -04:00
co-authored by Claude Opus 4.5
parent d230cffb5f
commit cb6a8df79b
+1 -5
View File
@@ -4,7 +4,6 @@ import sys
import os import os
import tty import tty
import termios import termios
import select
from typing import List, Tuple, Optional from typing import List, Tuple, Optional
from dataclasses import dataclass from dataclasses import dataclass
@@ -110,12 +109,9 @@ class TTYInput:
try: try:
ch = self.tty.read(1) ch = self.tty.read(1)
if ch == '\x1b': if ch == '\x1b':
# Use select to check if more chars available (escape sequence) # Read escape sequence - bytes arrive together from terminal
# Timeout of 0.05s - if nothing comes, it was just Escape
if select.select([self.fd], [], [], 0.05)[0]:
ch2 = self.tty.read(1) ch2 = self.tty.read(1)
if ch2 == '[': if ch2 == '[':
if select.select([self.fd], [], [], 0.05)[0]:
ch3 = self.tty.read(1) ch3 = self.tty.read(1)
if ch3 == 'A': return 'UP' if ch3 == 'A': return 'UP'
if ch3 == 'B': return 'DOWN' if ch3 == 'B': return 'DOWN'