fix(rawcli): Ctrl-/ key binding crashed launch ("Invalid key: c-/")
prompt_toolkit doesn't accept "c-/". Ctrl-/ is emitted as Ctrl-_ (0x1F) by terminals, so bind "c-_" (plus "c-t" as an always-available fallback) for the hex/binary toggle. install_key_bindings() now ignores any key name a prompt_toolkit build rejects, so a bad key can never crash launch. Regression test added. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -326,3 +326,13 @@ class TestCompleter:
|
||||
s.protocol, s.transponder = "hf14a", "NTAG215"
|
||||
cs = self._complete(s, "help GET")
|
||||
assert any(c.text == "GET_VERSION" for c in cs)
|
||||
|
||||
|
||||
class TestKeyBindings:
|
||||
def test_install_does_not_raise(self):
|
||||
# regression: "c-/" is not a valid prompt_toolkit key and used to crash launch
|
||||
from prompt_toolkit.key_binding import KeyBindings
|
||||
from pm3py.cli.rawcli.entry import install_key_bindings, TOGGLE_KEYS
|
||||
kb = KeyBindings()
|
||||
install_key_bindings(kb, RawSession())
|
||||
assert len(kb.bindings) >= len(TOGGLE_KEYS)
|
||||
|
||||
Reference in New Issue
Block a user