Skip to content
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

PR: Show calltips when 'Automatic insertion of parentheses, braces and brackets' is unchecked #3893

Merged
merged 4 commits into from
Dec 31, 2016
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions spyder/widgets/sourcecode/codeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2725,12 +2725,9 @@ def keyPressEvent(self, event):
self.stdkey_end(shift, ctrl)
elif text == '(' and not self.has_selected_text():
self.hide_completion_widget()
if self.close_parentheses_enabled:
self.handle_close_parentheses(text)
else:
self.insert_text(text)
elif text in ('[', '{') and not self.has_selected_text() \
and self.close_parentheses_enabled:
self.handle_close_parentheses(text)
elif (text in ('[', '{') and not self.has_selected_text() and
self.close_parentheses_enabled):
s_trailing_text = self.get_text('cursor', 'eol').strip()
if len(s_trailing_text) == 0 or \
s_trailing_text[0] in (',', ')', ']', '}'):
Expand Down Expand Up @@ -2798,11 +2795,10 @@ def keyPressEvent(self, event):
self.completion_text += text

def handle_close_parentheses(self, text):
Copy link
Member

Choose a reason for hiding this comment

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

Let's change this method to handle_parentheses instead. I think it's a more appropriate name given the changes you made.

if not self.close_parentheses_enabled:
return
position = self.get_position('cursor')
rest = self.get_text('cursor', 'eol').rstrip()
if not rest or rest[0] in (',', ')', ']', '}'):
valid = not rest or rest[0] in (',', ')', ']', '}')
if self.close_parentheses_enabled and valid:
self.insert_text('()')
cursor = self.textCursor()
cursor.movePosition(QTextCursor.PreviousCharacter)
Expand Down