File: key_bindings.py

package info (click to toggle)
iredis 1.9.1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,388 kB
  • sloc: python: 6,494; sh: 16; makefile: 13
file content (22 lines) | stat: -rw-r--r-- 642 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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