mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-08 21:54:54 +08:00
Move a bit of code
This commit is contained in:
@@ -281,19 +281,10 @@ class DiffParser(object):
|
|||||||
else:
|
else:
|
||||||
p_children = line_stmt.parent.children
|
p_children = line_stmt.parent.children
|
||||||
index = p_children.index(line_stmt)
|
index = p_children.index(line_stmt)
|
||||||
p_children = p_children[index:]
|
|
||||||
# There might be a random dedent where we have to stop copying.
|
|
||||||
# Invalid indents are ok, because the parser handled that
|
|
||||||
# properly before. An invalid dedent can happen, because a few
|
|
||||||
# lines above there was an invalid indent.
|
|
||||||
indentation = line_stmt.start_pos[1]
|
|
||||||
for i, c in enumerate(p_children):
|
|
||||||
if c.start_pos[1] < indentation:
|
|
||||||
p_children = p_children[:i]
|
|
||||||
|
|
||||||
from_ = self._nodes_tree.parsed_until_line + 1
|
from_ = self._nodes_tree.parsed_until_line + 1
|
||||||
copied_nodes = self._nodes_tree.copy_nodes(
|
copied_nodes = self._nodes_tree.copy_nodes(
|
||||||
p_children,
|
p_children[index:],
|
||||||
until_line_old,
|
until_line_old,
|
||||||
line_offset
|
line_offset
|
||||||
)
|
)
|
||||||
@@ -597,6 +588,15 @@ class _NodesTree(object):
|
|||||||
# issues.
|
# issues.
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
# There might be a random dedent where we have to stop copying.
|
||||||
|
# Invalid indents are ok, because the parser handled that
|
||||||
|
# properly before. An invalid dedent can happen, because a few
|
||||||
|
# lines above there was an invalid indent.
|
||||||
|
indentation = tree_nodes[0].start_pos[1]
|
||||||
|
for i, c in enumerate(tree_nodes):
|
||||||
|
if c.start_pos[1] < indentation:
|
||||||
|
tree_nodes = tree_nodes[:i]
|
||||||
|
|
||||||
self._get_insertion_node(tree_nodes[0])
|
self._get_insertion_node(tree_nodes[0])
|
||||||
|
|
||||||
new_nodes, self._working_stack, self.prefix = self._copy_nodes(
|
new_nodes, self._working_stack, self.prefix = self._copy_nodes(
|
||||||
|
|||||||
Reference in New Issue
Block a user