myclaude -r: 修快速连按方向键被退出 + 隐藏光标 + 退出删除行不留空行

- _read_key 改按需读 CSI 序列(方向键读到终止符即返回),连按 \x1b[B 不再被吞进同一序列误判为 ESC 退出
- picker 全程隐藏光标(\x1b[?25l),退出恢复(\x1b[?25h),末尾不再突兀闪现光标
- 退出改用 Delete Line(\x1b[{n}M)删除块区域,替代逐行清空,不再留下 N 个空行
- tests: 新增快速连按方向键回归测试
This commit is contained in:
Zhengshou Lai
2026-08-15 22:38:15 +08:00
parent c342c4e94a
commit 75a72a8b24
2 changed files with 67 additions and 17 deletions
+15
View File
@@ -340,3 +340,18 @@ class TestReadKey:
def test_escape(self) -> None:
assert _read_key_from_bytes(b"\x1b") == "esc"
def test_rapid_arrows_not_merged(self) -> None:
"""Back-to-back arrow keys stay distinct (no bleed into one ESC)."""
r, w = os.pipe()
try:
# 4 rapid down presses back-to-back, exactly as the terminal sends them
os.write(w, b"\x1b[B" * 4)
keys = [L._read_key(r) for _ in range(4)]
assert keys == ["down"] * 4
# bare ESC still reads as its own key afterwards
os.write(w, b"\x1b")
assert L._read_key(r) == "esc"
finally:
os.close(r)
os.close(w)