Repository navigation
Update correct tag tree jump progressions when splitting outer group - #8778
Merged
Merged
Conversation
saecki
force-pushed
the
fix-nested-links
branch
2 times, most recently
from
August 25, 2026 15:25
2c7f51e to
e6e0871
Compare
laurmaedje
reviewed
Aug 26, 2026
The issue was that this would look up the previous ID of the jump
progression in the list, intstead of just using the ID of the stack
entry. That jump progression in the list could have already been updated
by a previous splitting of groups. Thus jump progressions of a nested
group were updated instead of the one that we actually care about.
Here is an illustration of what happens with the two nested links in the
added test.
= 1. Initial break
After encountering the following tags:
```
start par-1
start link-1
start link-2
end par-1
```
We have the following intermediate tree:
```
- par-1
- link-1
- link-2
- link-1 (weak)
- link-2 (weak) <- here
```
= 2. New paragraph
Now we find the start tag of the second paragraph:
```
start par-2
```
It's naively inserted into the current tree
```
- par-1
- link-1
- link-2
- link-1 (weak)
- link-2 (weak)
- par-2 <- here
```
= 3. Break of inner link group (link-2)
Now we find the end tag of the inner link:
```
end link-2
```
The paragraph is moved out of the inner link, and a new link is added to
it instead. This somewhat transposes the nesting order, but in the end
it will all make sense. Because the newly added link was just closed,
we're still inside the paragraph group.
```
- par-1
- link-1
- link-2
- link-1 (weak)
- link-2 (weak)
- par-2 <- here
- link-2 (weak)
```
While doing this tree transformation we update the previous jump
progressions that jumped into the `par-2` of the previous tree
structure, to jump into the newly added `link-2` instead.
Thus updating the group id in the progression list, but not the group id
of the stack entry, that's still active.
= 4. Break of outer link group (link-1)
Now we find the end tag of the outer link:
```
end link-1
```
We move `par-2` out of the closed outer link (`link-1`) with a similar
transformation and add the nested `link-1`. All immediate children of
`par-2` will be moved into `link-1` instead. To make the transformation
complete we need to update the jump progressions that previously jumped
into `par-2` to jump into the newly added `link-1` instead.
```
- par-1
- link-1
- link-2
- link-1 (weak)
- link-2 (weak)
- par-2 <- here
- link-1 (weak)
- link-2 (weak)
```
This is were the bug came into place. The indirect lookup of the ID
would resolve the ID of the inner `link-2` instead.
```rs
let prev = tree.progressions[entry.prog_idx as usize];
```
The wrong progresssions were updated, and our newly added `link-1` would
never be visited by the progression list, because the progression still
jumped into `par-2`.
= 5. Link ancestor
Because we never visited the last `link-1` group, the link annotation
couldn't find its ancestor and would generate an internal error.
saecki
force-pushed
the
fix-nested-links
branch
from
August 26, 2026 08:51
e6e0871 to
a264d28
Compare
1 task done
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The issue was that this would look up the previous ID of the jump progression in the list, intstead of just using the ID of the stack entry. That jump progression in the list could have already been updated by a previous splitting of groups. Thus jump progressions of a nested group were updated instead of the one that we actually care about.
Here is an illustration of what happens with the two nested links in the added test.
= 1. Initial break
After encountering the following tags:
We have the following intermediate tree:
= 2. New paragraph
Now we find the start tag of the second paragraph:
It's naively inserted into the current tree
= 3. Break of inner link group (link-2)
Now we find the end tag of the inner link:
The paragraph is moved out of the inner link, and a new link is added to it instead. This somewhat transposes the nesting order, but in the end it will all make sense. Because the newly added link was just closed, we're still inside the paragraph group.
While doing this tree transformation we update the previous jump progressions that jumped into the
par-2of the previous tree structure, to jump into the newly addedlink-2instead. Thus updating the group id in the progression list, but not the group id of the stack entry, that's still active.= 4. Break of outer link group (link-1)
Now we find the end tag of the outer link:
We move
par-2out of the closed outer link (link-1) with a similar transformation and add the nestedlink-1. All immediate children ofpar-2will be moved intolink-1instead. To make the transformation complete we need to update the jump progressions that previously jumped intopar-2to jump into the newly addedlink-1instead.This is were the bug came into place. The indirect lookup of the ID would resolve the ID of the inner
link-2instead.The wrong progresssions were updated, and our newly added
link-1would never be visited by the progression list, because the progression still jumped intopar-2.= 5. Link ancestor
Because we never visited the last
link-1group, the link annotation couldn't find its ancestor and would generate an internal error.