diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 52ea4ebf..b970ac5e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 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