summaryrefslogtreecommitdiffstats
path: root/pgcli
diff options
context:
space:
mode:
authorAmjith Ramanujam <amjith.r@gmail.com>2019-10-23 14:11:44 -0700
committerOwen Stephens <owen@owenstephens.co.uk>2019-10-23 22:11:44 +0100
commitf25e49555aa53c740baaf685e9ed4b34a0a5b6f2 (patch)
tree4675dece773edddbc6060540ca17d8d03533cb6c /pgcli
parenta713b5d08b0fae4e55066f5438522a173f79606b (diff)
Fix the condition for <enter> key. (#1114)
* Fix the condition for <enter> key. * Improve the debug message and remove debug statement.
Diffstat (limited to 'pgcli')
-rw-r--r--pgcli/key_bindings.py6
-rw-r--r--pgcli/pgbuffer.py5
2 files changed, 9 insertions, 2 deletions
diff --git a/pgcli/key_bindings.py b/pgcli/key_bindings.py
index 6a4cb065..b9f869dc 100644
--- a/pgcli/key_bindings.py
+++ b/pgcli/key_bindings.py
@@ -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")
diff --git a/pgcli/pgbuffer.py b/pgcli/pgbuffer.py
index 51f9b869..8e842c97 100644
--- a/pgcli/pgbuffer.py
+++ b/pgcli/pgbuffer.py
@@ -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