Skip to content

bpo-40511: fix unnecessary flashing of calltips #20910

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

Merged

Conversation

taleinat
Copy link
Contributor

@taleinat taleinat commented Jun 16, 2020

Copy link
Contributor

@roseman roseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried it out, looks good!

@taleinat
Copy link
Contributor Author

Thanks for trying this out and giving some feedback, @roseman!

Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified that this patch fixes flashing in at least one case each of parens in string and bytes literals, comments, and expressions.

My first code concern is whether each new line is needed. I suspect some are either not or are not the best fix.

My second is whether the fix introduces regressions. Might tips be suppressed when needed? I tested both nested function calls such as int(float(a)) ('float(' open a float tip, 'a)' closes it and restores the int tip) and forced opens at various places. These continue working. To completely understand the new code and be more confident, I need to look at hyperparser.

I outlined a new non-gui open_calltip testcase and am willing to write it. A slightly different approach would be to add the new test code examples to the hyperparser test and then mock hyperparser for these tests.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@taleinat
Copy link
Contributor Author

taleinat commented Oct 28, 2020

Thanks for the review, @terryjreedy! 🙏

I have made the requested changes; please review again.

I outlined a new non-gui open_calltip testcase and am willing to write it. A slightly different approach would be to add the new test code examples to the hyperparser test and then mock hyperparser for these tests.

Let me know if you'd like me to write such tests or if you'd rather do so yourself.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A separate existing bug for another issue: if an inner call has no tip, the outer tip is closed anyway (a correct thing to do) but not restored when the the inner call is completed with ')'. To fix, we might either stack outer tips or flag nested tips.

But I don't want to make additional code changes (other than a docstring and a revised comment) until we have tests, which I will start now.

Comment on lines 60 to 62
if not sur_paren:
# Not inside parentheses: Don't open a calltip, and close one if
# currently open.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if not sur_paren:
# Not inside parentheses: Don't open a calltip, and close one if
# currently open.
if not sur_paren: # Outer call just closed by releasing ).

See response to your response below.

Copy link
Contributor Author

@taleinat taleinat Nov 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typing ')' is not the only case where this branch will be reached: it can also happen in various other cases via force_open_calltip_event().

return

# At this point, the current index is after an opening parenthesis, in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might later think about rewording or condensing the added comments, but tests are a higher priority.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

@terryjreedy
Copy link
Member

I think the tests I added are sufficient for this issue. open_calltip is covered except for some of the if branches. I plan to follow-up with a separate test PR, aiming for 100% coverage.

@terryjreedy
Copy link
Member

Tal, if you are too busy now, do you mind if I finish this so I can continue with followups?

@taleinat
Copy link
Contributor Author

taleinat commented Nov 1, 2020

@terryjreedy, I have made the requested changes; please review again.

I've also refactored the new code in test_calltip a bit, and somewhat condensed the comments you mentioned.

AFAICT that should address your review requests. If I've missed something, apologies in advance, please let me know and I'll handle it quickly.

@bedevere-bot
Copy link

Thanks for making the requested changes!

@terryjreedy: please review the changes made to this pull request.

Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the test change. The test failure was whitespace in the added docstring. My fault I presume. I will merge when the retest passes.

REs with re-specific \ escapes must be r-prefixed to avoid deprecation warning now, exception later. python -m test.test_idle prints them. I added it to the RE I added to mock Text.

@terryjreedy terryjreedy added needs backport to 3.8 needs backport to 3.9 only security fixes type-bug An unexpected behavior, bug, or error labels Nov 2, 2020
@terryjreedy terryjreedy merged commit da7bb7b into python:master Nov 2, 2020
@miss-islington
Copy link
Contributor

Thanks @taleinat for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 2, 2020
They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit da7bb7b)

Co-authored-by: Tal Einat <[email protected]>
@bedevere-bot
Copy link

GH-23093 is a backport of this pull request to the 3.9 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.9 only security fixes label Nov 2, 2020
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Nov 2, 2020
They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit da7bb7b)

Co-authored-by: Tal Einat <[email protected]>
@bedevere-bot
Copy link

GH-23094 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Nov 2, 2020
They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit da7bb7b)

Co-authored-by: Tal Einat <[email protected]>
miss-islington added a commit that referenced this pull request Nov 2, 2020
They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <[email protected]>
(cherry picked from commit da7bb7b)

Co-authored-by: Tal Einat <[email protected]>
@taleinat taleinat deleted the bpo-40511/IDLE-fix-parens-flashing-calltip branch November 2, 2020 06:57
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
They were occurring with both repeated 'force-calltip' invocations and by typing parentheses
 in expressions, strings, and comments in the argument code.

Co-authored-by: Terry Jan Reedy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants