-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Completions sometimes insert extraneous text #10798
Comments
Thanks for reporting this one @its-dhung , however, as you mention this issue is difficult to reproduce; at least I couldn't reproduce it on my machine by trying the aforementioned completion scenario |
What do you think about this one @ccordoba12 |
I'm leaving this for 4.1.0 to try to find a reproducible use case. |
I have exactly the same bug. VersionSpyder 4.0.0 with Kite, Python 3.6.9, Fedora 31. Dependenciescloudpickle >=0.5.0 : 1.2.2 (OK) |
I may have a hint of the error origin. I have a class with a method |
@andfoy, please take a look at this one. |
I think this is a separate issue, which I can reproduce |
@melsophos, PR #11400 should fix your aforementioned issue |
@its-dhung @ccordoba12 I'm still unable to reproduce this issue: |
@andfoy I can reproduce this reliably. In the video above, the first 2 usages of the completion Let me know if there's any info I could be logging to help you debug. |
@dalthviz, could you reproduce this one? |
@ccordoba12 I was able to reproduce this by changing the number of characters for automatic completion to 1 and decreasing the show automatic completions keyboard idle to 50: Seems like the extra characters are the ones typed before the automatic request for completion is done and shown in the completion widget for the first typed letter(s). So for example, if I type import j| # Autocompletion request is made
---------------------------------------------------------------------------------------------
import js| # 's' is typed and the completion widget pops up but it's actually showing
# completions for 'j'. Accepting the completion would insert elements at
# 'import j|'
---------------------------------------------------------------------------------------------
import json|s # Insertion at 'j|'. End cursor before '|s' |
Great work @dalthviz! So this is sort of a race condition in the completion widget. I think the problem is that Spyder takes some time to display the completion widget, so the additional characters the user types are not passed to the widget. And until the widget appears, they are not passed to the editor either. A possible solution would be to display the completion widget immediately when users select |
If multiple requests occur before displaying a widget, how about displaying the widget only for the last request? I'm not sure my code is the solution about this problem. def send():
max_req_id = max(
[key for key, item in self.requests.items()
if item['req_type'] == self.requests[req_id]['req_type']],
default=-1)
del self.requests[req_id]
# Response only to recent requests.
if req_id == max_req_id:
self.gather_and_send(request_responses) |
@ccordoba12 the patch of @ok97465 fixes the issue for me 🎉 @ok97465 could you open a PR with your patch, please? or if you prefer I could create the PR, whatever works best for you. Again, thanks for the fix suggestion and feedback @ok97465 ! |
@dalthviz Thank you for your review. I'll open a PR. |
Problem Description
When using a completion, sometimes extraneous text is inserted into the buffer.
What steps reproduce the problem?
See the video below:
What is the expected output? What do you see instead?
Expected:
this_message
should be inserted into the buffer.Actual: In this case,
this_message$is
was inserted into the buffer, where the$
denotes the final location of the cursor.This behavior seems intermittent. Sometimes the correct text is inserted, sometimes the extraneous text is inserted.
Versions
Python 3.7.0 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Darwin 19.0.0
Dependencies
The text was updated successfully, but these errors were encountered: