From cb6a8df79bad48d2360ad1de62fcbeaf1dd96d70 Mon Sep 17 00:00:00 2001 From: rob Date: Sun, 18 Jan 2026 04:52:47 -0400 Subject: [PATCH] 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 --- src/cmdforge/cli/picker.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/cmdforge/cli/picker.py b/src/cmdforge/cli/picker.py index 7567dd9..b5ef402 100644 --- a/src/cmdforge/cli/picker.py +++ b/src/cmdforge/cli/picker.py @@ -4,7 +4,6 @@ import sys import os import tty import termios -import select from typing import List, Tuple, Optional from dataclasses import dataclass @@ -110,17 +109,14 @@ class TTYInput: try: ch = self.tty.read(1) if ch == '\x1b': - # Use select to check if more chars available (escape sequence) - # Timeout of 0.05s - if nothing comes, it was just Escape - if select.select([self.fd], [], [], 0.05)[0]: - ch2 = self.tty.read(1) - if ch2 == '[': - if select.select([self.fd], [], [], 0.05)[0]: - ch3 = self.tty.read(1) - if ch3 == 'A': return 'UP' - if ch3 == 'B': return 'DOWN' - if ch3 == 'C': return 'RIGHT' - if ch3 == 'D': return 'LEFT' + # Read escape sequence - bytes arrive together from terminal + ch2 = self.tty.read(1) + if ch2 == '[': + ch3 = self.tty.read(1) + if ch3 == 'A': return 'UP' + if ch3 == 'B': return 'DOWN' + if ch3 == 'C': return 'RIGHT' + if ch3 == 'D': return 'LEFT' return ch finally: termios.tcsetattr(self.fd, termios.TCSANOW, self.old_settings)