1
0
Fork 0

Merge pull request #1367 from dbcli/j-bennet/1360-esc-enter-safe-multiline-mode

Esc + Enter should sumbit the query in safe multiline mode.
This commit is contained in:
Amjith Ramanujam 2022-09-14 15:24:11 -07:00 committed by GitHub
commit 2f88df95ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -7,6 +7,7 @@ Bug fixes:
* Fix exception when retrieving password from keyring ([issue 1338](https://github.com/dbcli/pgcli/issues/1338)).
* Fix using comments with special commands ([issue 1362](https://github.com/dbcli/pgcli/issues/1362)).
* Small improvements to the Windows developer experience
* Fix submitting queries in safe multiline mode ([1360](https://github.com/dbcli/pgcli/issues/1360)).
Internal:
---------
@ -21,7 +22,7 @@ Bug fixes:
----------
* Fix the bug with Redshift not displaying word count in status ([related issue](https://github.com/dbcli/pgcli/issues/1320)).
* Show the error status for CSV output format.
* Show the error status for CSV output format.
3.4.0 (2022/02/21)

View File

@ -9,7 +9,7 @@ from prompt_toolkit.filters import (
vi_mode,
)
from .pgbuffer import buffer_should_be_handled
from .pgbuffer import buffer_should_be_handled, safe_multi_line_mode
_logger = logging.getLogger(__name__)
@ -114,7 +114,7 @@ def pgcli_bindings(pgcli):
_logger.debug("Detected enter key.")
event.current_buffer.validate_and_handle()
@kb.add("escape", "enter", filter=~vi_mode)
@kb.add("escape", "enter", filter=~vi_mode & ~safe_multi_line_mode(pgcli))
def _(event):
"""Introduces a line break regardless of multi-line mode or not."""
_logger.debug("Detected alt-enter key.")

View File

@ -22,6 +22,17 @@ mode, which by default will insert new lines on Enter.
"""
def safe_multi_line_mode(pgcli):
@Condition
def cond():
_logger.debug(
'Multi-line mode state: "%s" / "%s"', pgcli.multi_line, pgcli.multiline_mode
)
return pgcli.multi_line and (pgcli.multiline_mode == "safe")
return cond
def buffer_should_be_handled(pgcli):
@Condition
def cond():