-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
bpo-40511: fix unnecessary flashing of calltips #20910
Conversation
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.
tried it out, looks good!
Thanks for trying this out and giving some feedback, @roseman! |
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 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.
When you're done making the requested changes, leave the comment: |
Thanks for the review, @terryjreedy! 🙏 I have made the requested changes; please review again.
Let me know if you'd like me to write such tests or if you'd rather do so yourself. |
Thanks for making the requested changes! @terryjreedy: please review the changes made to this pull request. |
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.
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.
Lib/idlelib/calltip.py
Outdated
if not sur_paren: | ||
# Not inside parentheses: Don't open a calltip, and close one if | ||
# currently open. |
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.
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.
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.
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()
.
Lib/idlelib/calltip.py
Outdated
return | ||
|
||
# At this point, the current index is after an opening parenthesis, in |
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 might later think about rewording or condensing the added comments, but tests are a higher priority.
When you're done making the requested changes, leave the comment: |
I think the tests I added are sufficient for this issue. open_calltip is covered except for some of the |
Tal, if you are too busy now, do you mind if I finish this so I can continue with followups? |
Co-authored-by: Terry Jan Reedy <[email protected]>
@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. |
Thanks for making the requested changes! @terryjreedy: please review the changes made to this pull request. |
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 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.
Thanks @taleinat for the PR, and @terryjreedy for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9. |
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]>
GH-23093 is a backport of this pull request to the 3.9 branch. |
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]>
GH-23094 is a backport of this pull request to the 3.8 branch. |
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]>
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]>
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]>
https://bugs.python.org/issue40511