From 020a1019b6b4bd33851de7886e76e30e179f36c6 Mon Sep 17 00:00:00 2001 From: Liam Hennebury Date: Wed, 27 Sep 2023 12:20:56 -0300 Subject: [PATCH] Add key binding to accept completion with the right-arrow key --- litecli/key_bindings.py | 8 ++++++++ tests/test_smart_completion_public_schema_only.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/litecli/key_bindings.py b/litecli/key_bindings.py index 44d59d2..96eed50 100644 --- a/litecli/key_bindings.py +++ b/litecli/key_bindings.py @@ -81,4 +81,12 @@ def _(event): b = event.app.current_buffer b.complete_state = None + @kb.add("right", filter=completion_is_selected) + def _(event): + """Accept the completion that is selected in the dropdown menu.""" + _logger.debug("Detected right-arrow key.") + + b = event.app.current_buffer + b.complete_state = None + return kb diff --git a/tests/test_smart_completion_public_schema_only.py b/tests/test_smart_completion_public_schema_only.py index e532118..c4a076a 100644 --- a/tests/test_smart_completion_public_schema_only.py +++ b/tests/test_smart_completion_public_schema_only.py @@ -376,7 +376,7 @@ def test_auto_escaped_col_names(completer, complete_event): Completion(text="id", start_position=0), ] + list(map(Completion, completer.functions)) - + [Completion(text="`select`", start_position=0)] + + [Completion(text="select", start_position=0)] + list(map(Completion, sorted(completer.keywords))) )