mirror of https://github.com/dbcli/pgcli
Fix the condition for <enter> key. (#1114)
* Fix the condition for <enter> key. * Improve the debug message and remove debug statement.
This commit is contained in:
parent
a713b5d08b
commit
f25e49555a
|
@ -1,7 +1,7 @@
|
|||
repos:
|
||||
- repo: https://github.com/ambv/black
|
||||
- repo: https://github.com/psf/black
|
||||
rev: stable
|
||||
hooks:
|
||||
- id: black
|
||||
language_version: python3.6
|
||||
language_version: python3.7
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ def pgcli_bindings(pgcli):
|
|||
(accept current selection).
|
||||
|
||||
"""
|
||||
_logger.debug("Detected enter key.")
|
||||
_logger.debug("Detected enter key during completion selection.")
|
||||
|
||||
event.current_buffer.complete_state = None
|
||||
event.app.current_buffer.complete_state = None
|
||||
|
@ -102,9 +102,11 @@ def pgcli_bindings(pgcli):
|
|||
# history search, and one of several conditions are True
|
||||
@kb.add(
|
||||
"enter",
|
||||
filter=~(has_completions | is_searching) & buffer_should_be_handled(pgcli),
|
||||
filter=~(completion_is_selected | is_searching)
|
||||
& buffer_should_be_handled(pgcli),
|
||||
)
|
||||
def _(event):
|
||||
_logger.debug("Detected enter key.")
|
||||
event.current_buffer.validate_and_handle()
|
||||
|
||||
@kb.add("escape", "enter")
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
from __future__ import unicode_literals
|
||||
import logging
|
||||
|
||||
from prompt_toolkit.enums import DEFAULT_BUFFER
|
||||
from prompt_toolkit.filters import Condition
|
||||
from prompt_toolkit.application import get_app
|
||||
from .packages.parseutils.utils import is_open_quote
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _is_complete(sql):
|
||||
# A complete command is an sql statement that ends with a semicolon, unless
|
||||
|
@ -24,9 +27,11 @@ def buffer_should_be_handled(pgcli):
|
|||
@Condition
|
||||
def cond():
|
||||
if not pgcli.multi_line:
|
||||
_logger.debug("Not in multi-line mode. Handle the buffer.")
|
||||
return True
|
||||
|
||||
if pgcli.multiline_mode == "safe":
|
||||
_logger.debug("Multi-line mode is set to 'safe'. Do NOT handle the buffer.")
|
||||
return False
|
||||
|
||||
doc = get_app().layout.get_buffer_by_name(DEFAULT_BUFFER).document
|
||||
|
|
Loading…
Reference in New Issue