mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 21:54:54 +08:00
Fix diff parser: Skip last leaves for last line offset leaves
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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('')
|
||||
|
||||
Reference in New Issue
Block a user