             # row where it was opened
             indentLevel = @editor.indentationForBufferRow(lastClosedRow[0])
 
-            if lastFunctionRow == row - 1
-                # we just finished defining a function, need to increase indentation
+            if lastColonRow == row - 1
+                # we just finished def/for/if/elif/else/try/except etc. block,
+                # need to increase indent level by 1.
                 indentLevel += 1
 
             @editor.setIndentationForBufferRow(row, indentLevel)


                    # Similar to above, we've already skipped all irrelevant characters,
                    # so if we saw a colon earlier in this line, then we would have
                    # incorrectly thought it was the end of a function definition when
                    # it was actually a dictionary being defined, reset the lastFunctionRow
                    # variable to whatever it was when we started parsing this line.
                    lastFunctionRow = lastLastFunctionRow

                    if c == ':'
                        lastFunctionRow = row
                    else if c in '})]' and openBracketStack.length
                        # Note that the .pop() will take the element off of the openBracketStack
                        # as it adds it to the array for lastClosedRow.

    # i.e., did this string start with ' or with "?
    stringDelimiter = []
    # this is the row of the last function definition
    lastColonRow = NaN

    # NOTE: this parsing will only be correct if the python code is well-formed
    #       statements like "[0, (1, 2])" might break the parsing
