-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,7 +92,7 @@ def _(event): | |
(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 _(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) | ||
& buffer_should_be_handled(pgcli), | ||
) | ||
def _(event): | ||
_logger.debug("Detected enter key.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)? |
||
event.current_buffer.validate_and_handle() | ||
|
||
@kb.add("escape", "enter") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thancompletion_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 lettera
. 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.