1
0
Fork 0
iredis/iredis/key_bindings.py
Daniel Baumann 031879240c
Adding upstream version 1.9.1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
2025-02-09 16:57:44 +01:00

22 lines
642 B
Python

import logging
from prompt_toolkit.filters import completion_is_selected
from prompt_toolkit.key_binding import KeyBindings
logger = logging.getLogger(__name__)
kb = KeyBindings()
@kb.add("enter", filter=completion_is_selected)
def _(event):
"""Makes the enter key work as the tab key only when showing the menu.
In other words, don't execute query when enter is pressed in
the completion dropdown menu, instead close the dropdown menu
(accept current selection).
"""
logger.debug("Detected enter key.")
event.current_buffer.complete_state = None
b = event.app.current_buffer
b.complete_state = None