test(rawcli): guard Ctrl-t breadcrumb flips 0x<->0b + redraw
Closes the last loose end from the byte-line autocomplete fix: the entry-mode toggle correctly flips the breadcrumb prefix (0x <-> 0b) and requests a redraw. Adds test_toggle_updates_breadcrumb_prefix and updates the roadmap. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -886,6 +886,26 @@ class TestKeyBindings:
|
||||
toggle.handler(event)
|
||||
assert s.entry_mode == "bin" and buf.text == "30" # mode flipped, buffer intact
|
||||
|
||||
def test_toggle_updates_breadcrumb_prefix(self):
|
||||
# the toggle flips the breadcrumb entry prefix 0x <-> 0b and requests a redraw
|
||||
from types import SimpleNamespace
|
||||
from prompt_toolkit.key_binding import KeyBindings
|
||||
from prompt_toolkit.buffer import Buffer
|
||||
from pm3py.cli.rawcli.entry import install_key_bindings
|
||||
s = RawSession()
|
||||
kb = KeyBindings()
|
||||
install_key_bindings(kb, s)
|
||||
toggle = next(b for b in kb.bindings
|
||||
if getattr(b.keys[0], "value", b.keys[0]) in ("c-t", "c-_"))
|
||||
redraws = []
|
||||
ev = SimpleNamespace(current_buffer=Buffer(), data="",
|
||||
app=SimpleNamespace(invalidate=lambda: redraws.append(1)))
|
||||
assert "0x" in s.breadcrumb() and "0b" not in s.breadcrumb()
|
||||
toggle.handler(ev)
|
||||
assert "0b" in s.breadcrumb() and s.entry_prefix == "0b" and redraws # flipped + redraw
|
||||
toggle.handler(ev)
|
||||
assert "0x" in s.breadcrumb() and "0b" not in s.breadcrumb() # and back
|
||||
|
||||
def test_digit_binding_tracks_per_byte_base(self):
|
||||
# replay keystrokes through the real digit binding: 30 (hex) then binary -> 30 00000100
|
||||
from types import SimpleNamespace
|
||||
|
||||
Reference in New Issue
Block a user