Skip to content

Commit

Permalink
fix indentation error at start of line and PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
pwoosam committed Dec 11, 2016
1 parent bc93ded commit 0d3bfbe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions spyder/widgets/sourcecode/codeeditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1917,17 +1917,15 @@ def fix_indent(self, forward=True, comment_or_string=False):
diff_curly = 0
add_indent = False
prevline = None
if not self.get_block_indentation(block_nb - 1):
return False
for prevline in range(block_nb-1, -1, -1):
cursor.movePosition(QTextCursor.PreviousBlock)
prevtext = to_text_string(cursor.block().text()).rstrip()

if prevtext:

if (prevtext.strip().endswith(')')
or prevtext.strip().endswith(']')
or prevtext.strip().endswith('}')):
if (prevtext.strip().endswith(')') or \
prevtext.strip().endswith(']') or \
prevtext.strip().endswith('}')):

comment_or_string = True # prevent further parsing

Expand Down Expand Up @@ -2010,6 +2008,10 @@ def fix_indent(self, forward=True, comment_or_string=False):
# No indentation fix is necessary
return False

if not self.get_block_indentation(block_nb - 1) and \
not comment_or_string:
return False

if correct_indent >= 0:
cursor = self.textCursor()
cursor.movePosition(QTextCursor.StartOfBlock)
Expand Down

0 comments on commit 0d3bfbe

Please sign in to comment.