Skip to content

Commit

Permalink
Merge pull request #2615 from Beta-Alf/master
Browse files Browse the repository at this point in the history
Fix error when indenting on the first line of a file
  • Loading branch information
ccordoba12 committed Aug 20, 2015
2 parents 31cd972 + 902bff9 commit 31e7777
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spyderlib/widgets/sourcecode/codeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1883,6 +1883,7 @@ def fix_indent(self, forward=True, comment_or_string=False):
# find the line that contains our scope
diff = 0
add_indent = False
prevline = None
for prevline in range(block_nb-1, -1, -1):
cursor.movePosition(QTextCursor.PreviousBlock)
prevtext = to_text_string(cursor.block().text()).rstrip()
Expand All @@ -1903,6 +1904,10 @@ def fix_indent(self, forward=True, comment_or_string=False):
break

indent = self.get_block_indentation(block_nb)

if not prevline:
return False

correct_indent = self.get_block_indentation(prevline)

if add_indent:
Expand Down

0 comments on commit 31e7777

Please sign in to comment.