diff --git a/parso/python/diff.py b/parso/python/diff.py index 719f3ed..808d6de 100644 --- a/parso/python/diff.py +++ b/parso/python/diff.py @@ -466,6 +466,10 @@ class _NodesTreeNode(object): if self._children_groups: children_group = self._children_groups[-1] last_leaf = children_group.last_line_offset_leaf + while last_leaf.type == 'error_leaf' \ + and last_leaf.token_type in _INDENTATION_TOKENS: + last_leaf = last_leaf.get_previous_leaf() + line = last_leaf.end_pos[0] + children_group.line_offset # Newlines end on the next line, which means that they would cover diff --git a/test/test_diff_parser.py b/test/test_diff_parser.py index 7121e70..baf3de6 100644 --- a/test/test_diff_parser.py +++ b/test/test_diff_parser.py @@ -1097,3 +1097,14 @@ def test_all_sorts_of_indentation(differ): differ.initialize(code1) differ.parse(code2, copies=2, parsers=3, expect_error_leaves=True) differ.parse(code1, copies=1, parsers=3) + + code3 = dedent('''\ + if 1: + a + b + c + d + \x00 + ''') + differ.parse(code3, parsers=2, expect_error_leaves=True) + differ.parse('')