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

Fix error when indenting on the first line of a file #2615

Merged
merged 1 commit into from
Aug 20, 2015
Merged
Changes from all 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
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