-
-
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
Automatically add parens for function completions #2371
Automatically add parens for function completions #2371
Conversation
'method']: | ||
return | ||
edit = self.textedit | ||
s_trailing_text = edit.get_text('cursor', 'eol').strip() |
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.
Why not rstrip
instead of strip
here?
Added the new method to handle close parens. |
I'm not sure why the check for the other characters is there, but I'm sure someone had a valid reason. 😄 |
As a bonus, we get the calltip now! |
0b3745a
to
16c5e6e
Compare
Rebased after icon merge. |
return | ||
position = self.get_position('cursor') | ||
rest = self.get_text('cursor', 'eol').rstrip() | ||
if (len(rest) == 0 or rest[0] 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.
not rest
is more pythonic than len(rest) == 0
.
Also the surrounding parenthesis are not necessary.
I added a few style comments. These trailing whitespaces are really annoying... |
Automatically add () for function completions Rename variable for clarity Create a new method to handle close parens Revert trailing spaces More fixes Style fixes
69fdaec
to
6ad745a
Compare
Fixed! |
This is a really nice addition! And it's working as expected :-) I just have one question: could we make this work when users press
you won't get parenthesis nicely inserted (which, by the way, also shows you the signature tooltip). |
If that's not possible, we should seriously consider to tackle issue #1914 :-) |
Works now! |
I'm seeing this error in the internal console (with PyQt5 only) when pressing Traceback (most recent call last):
File "/home/carlos/Projects/spyder/github-repo/spyderlib/utils/introspection/plugin_manager.py", line 56, in _handle_timeout
debug_print('got timeout: %s' % self.plugins)
AttributeError: 'NoneType' object has no attribute 'plugins' An example to generate this
After this message is shown, each time parens are introduced the same error appears again. The error seems unrelated to this PR. So it's up to you @blink1073, if you want to fix it here or leave it for later :-) |
I'd say leave that one for a different issue. |
Ok, merging then ;-) |
…tion Automatically add parens for function completions
Fixes #680. Automatically appends parens to completions that are known to be a
function
,method
, orclass
, respecting the same rules as the standard auto parens in the code editor.