Commit ea9bda2e authored by eckhart's avatar eckhart
Browse files

- sync commit

parent f2162cfb
......@@ -385,6 +385,15 @@ class Node(
def init_pos(self, pos: int, overwrite: bool = False) -> 'Node':
(Re-)initialize position value. Usually, the parser guard
(`parsers.add_parser_guard()`) takes care of assigning the
position in the document to newly created nodes. However,
where Nodes are created outside the reach of the parser
guard, their document-position must be assigned manually.
This function recursively reassigns the position values
of the child nodes, too.
if overwrite or self._pos < 0:
self._pos = pos
for err in self._errors:
......@@ -394,7 +403,7 @@ class Node(
# recursively adjust pos-values of all children
offset = self.pos
for child in self.children:
child.init_pos(offset, overwrite)
offset = child.pos + len(child)
return self
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment