From 419d9e31746e69fabf58662e6c0f4182bb6942d0 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Tue, 24 Mar 2020 22:03:29 +0100 Subject: [PATCH] Diff parser: Fix a few more indentation issues --- parso/python/diff.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/parso/python/diff.py b/parso/python/diff.py index 894119a..e69d2ed 100644 --- a/parso/python/diff.py +++ b/parso/python/diff.py @@ -547,10 +547,9 @@ class _NodesTree(object): # having the right indentation. break elif tree_node.type == 'file_input': - if indentation > 0: + if indentation > 0 and indentation != node.get_latest_indentation(): if previous_node is None: - if indentation != node.get_latest_indentation(): - add_error_leaf = 'INDENT' + add_error_leaf = 'INDENT' else: node = previous_node add_error_leaf = 'ERROR_DEDENT' @@ -633,6 +632,7 @@ class _NodesTree(object): if c.start_pos[1] < indentation: tree_nodes = tree_nodes[:i] + old_working_stack = list(self._working_stack) add_error_leaf, _ = self._get_insertion_node(tree_nodes[0]) new_nodes, self._working_stack, self.prefix = self._copy_nodes( @@ -643,6 +643,8 @@ class _NodesTree(object): self.prefix, add_error_leaf=add_error_leaf, ) + if not new_nodes: + self._working_stack = old_working_stack return new_nodes def _copy_nodes(self, working_stack, nodes, until_line, line_offset,