Skip to content
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 2 commits into from
Oct 23, 2019
Merged

Fix the condition for <enter> key. #1114

merged 2 commits into from
Oct 23, 2019

Conversation

amjith
Copy link
Member

@amjith amjith commented Oct 22, 2019

Description

Fix the non-multi line case where the enter key was not recognized when the completion menu was open.

@amjith amjith requested a review from owst October 22, 2019 03:38
@codecov-io
Copy link

codecov-io commented Oct 22, 2019

Codecov Report

Merging #1114 into master will increase coverage by 0.15%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
pgcli/key_bindings.py 44.44% <50%> (+1.04%) ⬆️
pgcli/pgbuffer.py 66.66% <75%> (+1.96%) ⬆️
pgcli/pgexecute.py 84.42% <0%> (+0.31%) ⬆️
pgcli/packages/sqlcompletion.py 97.68% <0%> (+0.33%) ⬆️
pgcli/encodingutils.py 100% <0%> (+16.66%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a713b5d...e10ab12. Read the comment docs.

@@ -23,10 +26,13 @@ def _is_complete(sql):
def buffer_should_be_handled(pgcli):
@Condition
def cond():
# import wdb; wdb.set_trace()
Copy link
Contributor

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.")
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

@owst owst merged commit f25e495 into master Oct 23, 2019
@j-bennet j-bennet deleted the fix-non-multiline branch September 14, 2022 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants