Diff parser: Make sure dedent start pos are matching

This commit is contained in:
Dave Halter
2020-03-24 22:27:04 +01:00
parent 419d9e3174
commit 43651ef219
2 changed files with 7 additions and 5 deletions

View File

@@ -456,7 +456,7 @@ class _NodesTreeNode(object):
if add_error_leaf == 'INDENT': if add_error_leaf == 'INDENT':
pos = children_part[0].start_pos pos = children_part[0].start_pos
else: else:
pos = children[-1].end_pos pos = children_part[0].start_pos[0], 0
children.append(PythonErrorLeaf(add_error_leaf, '', pos)) children.append(PythonErrorLeaf(add_error_leaf, '', pos))
children += children_part children += children_part
self.tree_node.children = children self.tree_node.children = children
@@ -547,11 +547,13 @@ class _NodesTree(object):
# having the right indentation. # having the right indentation.
break break
elif tree_node.type == 'file_input': elif tree_node.type == 'file_input':
if indentation > 0 and indentation != node.get_latest_indentation(): latest_indentation = node.get_latest_indentation()
if previous_node is None: if indentation > 0 and indentation != latest_indentation:
if previous_node is None and indentation > latest_indentation:
add_error_leaf = 'INDENT' add_error_leaf = 'INDENT'
else: else:
node = previous_node if previous_node is not None:
node = previous_node
add_error_leaf = 'ERROR_DEDENT' add_error_leaf = 'ERROR_DEDENT'
break break
previous_node = node previous_node = node

View File

@@ -47,7 +47,7 @@ def _assert_nodes_are_equal(node1, node2):
assert node1.value == node2.value assert node1.value == node2.value
#assert node1.type == node2.type #assert node1.type == node2.type
assert node1.prefix == node2.prefix assert node1.prefix == node2.prefix
#assert node1.start_pos == node2.start_pos assert node1.start_pos == node2.start_pos
return return
else: else:
try: try: