-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the condition for <enter> key. #1114
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1114 +/- ##
==========================================
+ Coverage 84.33% 84.48% +0.15%
==========================================
Files 21 21
Lines 2509 2514 +5
==========================================
+ Hits 2116 2124 +8
+ Misses 393 390 -3
Continue to review full report at Codecov.
|
pgcli/pgbuffer.py
Outdated
@@ -23,10 +26,13 @@ def _is_complete(sql): | |||
def buffer_should_be_handled(pgcli): | |||
@Condition | |||
def cond(): | |||
# import wdb; wdb.set_trace() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this have been deleted?
) | ||
def _(event): | ||
_logger.debug("Detected enter key.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the same debug line a few lines above - should we make the output distinct (maybe add "- handling buffer" or similar)?
@@ -102,9 +102,11 @@ def _(event): | |||
# 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recall using has_completions
rather than completion_is_selected
in #1109 consciously, but I don't remember why. Can you give an example key-press sequence to show where the existing behaviour causes issues? I use multi-line and vim mode, so it's quite possible that I didn't fully test the emacs/single-line mode - apologies for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also tried to add a feature test for keypress handling in #1109, but ran into issues (I was having trouble sending the correct keypress sequences as I recall).
It'd be nice if we could add some tests in this area, as I think it's important to preserve a consistent UI. Do you know if anyone has tried before - or whether it's even possible to test the key press handling such as this in a feature test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reproducible key sequence:
Ensure multiline mode is OFF either via the config file or by toggling it via F3 key.
SELECT a
When you type SELECT a
it will pop up a completion menu with possible suggestions for the letter a
. If you press enter it should submit the command to the server but instead a newline is inserted with the completion menu kept open.
This PR fixes that situation.
Description
Fix the non-multi line case where the enter key was not recognized when the completion menu was open.