Skip to content

Commit

Permalink
Correctly unindent for Python language only
Browse files Browse the repository at this point in the history
  • Loading branch information
remisalmon committed Apr 15, 2020
1 parent beb9a46 commit 5354d54
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions spyder/plugins/editor/widgets/codeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3982,7 +3982,9 @@ 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.rstrip()):
if self.language == 'Python':
prevtxt = prevtxt.rstrip()
if ind(leading_text) == ind(prevtxt):
self.unindent(force=True)
insert_text(event)
elif key == Qt.Key_Space and not shift and not ctrl \
Expand All @@ -3993,7 +3995,9 @@ 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.rstrip()):
if self.language == 'Python':
prevtxt = prevtxt.rstrip()
if ind(leading_text) == ind(prevtxt):
self.unindent(force=True)
insert_text(event)
elif key == Qt.Key_Tab and not ctrl:
Expand Down

0 comments on commit 5354d54

Please sign in to comment.