Skip to content

Commit

Permalink
Merge pull request #3893 from mariacamilaremolinagutierrez/fixes_issu…
Browse files Browse the repository at this point in the history
…e_3809

PR: Show calltips when 'Automatic insertion of parentheses, braces and brackets' is unchecked
  • Loading branch information
ccordoba12 authored Dec 31, 2016
2 parents 3f82769 + ced6731 commit d06edff
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 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_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 @@ -2797,12 +2794,12 @@ def keyPressEvent(self, event):
if self.is_completion_widget_visible() and text:
self.completion_text += text

def handle_close_parentheses(self, text):
if not self.close_parentheses_enabled:
return
def handle_parentheses(self, text):
"""Handle left and right parenthesis depending on editor config."""
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

0 comments on commit d06edff

Please sign in to comment.