Skip to content

Commit

Permalink
Fix #10148 (for valid Python code)
Browse files Browse the repository at this point in the history
Does not fix the original issue where for ex. a `if` statement is immediately followed by a `else` statement (not valid Python)

To fix the original issue, `if ind(leading_text) == ind(prevtxt.rstrip()) and not prevtxt[-1] == ':':` works but is unnecessary in my opinion
  • Loading branch information
remisalmon committed Apr 15, 2020
1 parent ddfb324 commit beb9a46
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spyder/plugins/editor/widgets/codeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3982,7 +3982,7 @@ def insert_text(event):
ind = lambda txt: len(txt)-len(txt.lstrip())
prevtxt = to_text_string(self.textCursor(
).block().previous().text())
if ind(leading_text) == ind(prevtxt):
if ind(leading_text) == ind(prevtxt.rstrip()):
self.unindent(force=True)
insert_text(event)
elif key == Qt.Key_Space and not shift and not ctrl \
Expand All @@ -3993,7 +3993,7 @@ def insert_text(event):
ind = lambda txt: len(txt)-len(txt.lstrip())
prevtxt = to_text_string(self.textCursor(
).block().previous().text())
if ind(leading_text) == ind(prevtxt):
if ind(leading_text) == ind(prevtxt.rstrip()):
self.unindent(force=True)
insert_text(event)
elif key == Qt.Key_Tab and not ctrl:
Expand Down

0 comments on commit beb9a46

Please sign in to comment.