This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IDLE: Restore or keep calltip when needed
Type: behavior Stage: test needed
Components: IDLE Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: terry.reedy Nosy List: taleinat, terry.reedy
Priority: normal Keywords: patch

Created on 2020-11-02 05:24 by terry.reedy, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 23098 open terry.reedy, 2020-11-02 07:23
PR 23100 open taleinat, 2020-11-02 07:37
Messages (3)
msg380180 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-11-02 05:24
If one types 'int(' an int calltip is displayed.  If one adds 'float(' then the float calltip is displayed instead.  If one adds '"3.1")', the int calltip is restored.  (Actually a new int calltip.)  Finally, if one closes with ')', the int calltip is removed.

If, after 'int(', one adds instead 'f(', where f has no accessible signature or docstring and hence no calltip, the int calltip is dropped with no replacement.  When f is closed, the int calltip is not restored because open_calltip in

    def refresh_calltip_event(self, event):  # Bound to ')'.
        if self.active_calltip and self.active_calltip.tipwindow:
            self.open_calltip(False)

is not called because there is no existing calltip.

This issue is about somehow having the int calltip after the f call.  Possibilities.

1. Do not drop the int calltip when an inner call has none.

2. Give the inner call a fake calltip, something like "f(<unknown>".  Again, revise open_calltip.

3. Drop the outer calltip and set a 'nested_call flag in open_calltip and test it with 'or' in refresh_calltip_event (and unset the flag -- conditionally?) to restore it.

4. Add a calltip stack and test it for not empty in refresh_calltip_event. 

Tal, any opinions on the desired behavior.  I believe the #40511 revision should make any of the above, with 1 and 2 being easiest and safest.  A problem with 3 and 4 is that the text cursor can be moved out of the call and the calltip closed without the call being completed with ')'.

I want to add more tests first.
msg380190 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2020-11-02 07:38
We already have a "<<refresh-calltip>>" virtual event which is triggered upon typing a closing parenthesis ')'. We could just have it always call "open_calltip()" rather than only doing so when one is already open.

See PR GH-23100.
msg380191 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-11-02 07:52
I dislike the idea of creating a Hyperparser and calling get_surrounding_brackets on every ).  For (, the open is the ( just typed and the close is typically the newline to the right.  For ), the open may be several lines back.  I will test for noticeable delay after sleeping.
History
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86405
2020-11-02 07:52:09terry.reedysetmessages: + msg380191
stage: patch review -> test needed
2020-11-02 07:38:56taleinatsetmessages: - msg380188
2020-11-02 07:38:31taleinatsetmessages: + msg380190
2020-11-02 07:37:49taleinatsetpull_requests: + pull_request22014
2020-11-02 07:36:47taleinatsetmessages: + msg380188
2020-11-02 07:23:04terry.reedysetkeywords: + patch
stage: test needed -> patch review
pull_requests: + pull_request22012
2020-11-02 05:26:30terry.reedysettitle: IDLE: Restore calltip when needed -> IDLE: Restore or keep calltip when needed
2020-11-02 05:24:17terry.reedycreate