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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user