diff options
author | Jonathan Slenders <jonathan@slenders.be> | 2016-07-20 23:03:16 +0200 |
---|---|---|
committer | Jonathan Slenders <jonathan@slenders.be> | 2016-07-20 23:03:16 +0200 |
commit | c6f29d94aca24513c847196df7ed1b4e1b21ce9f (patch) | |
tree | d4c7d3ba7b46e4b8a6649ec82098ea3eb2e9ee25 | |
parent | 33b22b2098aa8109975e2e98b876b076b012b057 (diff) |
Bugfix in ControlUp/ControlDown key bindings + added tests.
-rw-r--r-- | prompt_toolkit/key_binding/bindings/named_commands.py | 4 | ||||
-rw-r--r-- | tests/test_cli.py | 8 |
2 files changed, 10 insertions, 2 deletions
diff --git a/prompt_toolkit/key_binding/bindings/named_commands.py b/prompt_toolkit/key_binding/bindings/named_commands.py index dff8cb4a..5bde1cc8 100644 --- a/prompt_toolkit/key_binding/bindings/named_commands.py +++ b/prompt_toolkit/key_binding/bindings/named_commands.py @@ -130,14 +130,14 @@ def accept_line(event): @register('previous-history') def previous_history(event): " Move `back' through the history list, fetching the previous command. " - event.current_buffer.history_backward(count=event.count) + event.current_buffer.history_backward(count=event.arg) @register('next-history') def next_history(event): " Move `forward' through the history list, fetching the next command. " - event.current_buffer.history_forward(count=event.count) + event.current_buffer.history_forward(count=event.arg) @register('beginning-of-history') diff --git a/tests/test_cli.py b/tests/test_cli.py index 3f49b0d1..1072cfa9 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -259,6 +259,14 @@ def test_emacs_history_bindings(): result, cli = _feed_cli_with_input('another item\x1b[A\x1b[a\x1b>\n', history=history) assert result.text == 'another item' + # ControlUp (previous-history) + result, cli = _feed_cli_with_input('\x1b[1;5A\n', history=history) + assert result.text == 'another item' + + # Esc< ControlDown (beginning-of-history, next-history) + result, cli = _feed_cli_with_input('\x1b<\x1b[1;5B\n', history=history) + assert result.text == 'line2 second input' + def test_emacs_reverse_search(): history = _history() |