Repository navigation
Conversation
…ode with a text sibling When a match ended exactly where the TextNode ended and the node still had a TextNode sibling, registerLexicalTextEntity re-ran getMatch over the combined text and bailed out unless that match started at offset 0 of the whole node. Matches that had already been replaced or skipped were part of that combined text, so any match that did not start the node - typically the last match of several in the same node - was never replaced. Compare against the text that is still to be processed and against the current match's own start offset instead of 0.
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 8, 2026 22:03
|
@LeSingh1 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
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.
Description
registerLexicalTextEntitysilently skips a match when the match ends at the end of its TextNode and does not start at offset 0. In #5466 the reporter's${Tenant.Zip}and${Facility.Zip}never becameVariableNodes, and they found the tell themselves: excluding the trailing}from the selection made the transform work, and the problem only ever hit the last match in a node when that match also ended the node.The transform walks a node replacing matches one at a time. Once a match is consumed, the loop keeps a
textcursor holding only the text still to be processed. When the remaining text runs out, the node's match might be continued by the next sibling — a${Tenant.in one node andZip}in the next — so the code re-runsgetMatchover the combined text and requires the result to line up before replacing.Two things were wrong with that check:
getMatchovercurrentNode.getTextContent() + nextSibling.getTextContent(), the whole node text, rather than the text still to be processed, andnextMatch.start === 0.Those only agree when the match starts at offset 0 of the node. For any later match,
nextMatch.startis the offset within the full node text, never 0, so the function returned early and left the match untransformed. The combined text is now built from the remaining text, and the check compares againstmatch.start, which is the same coordinate space.Closes #5466
Test plan
packages/lexical-text/src/__tests__/unit/Issue5466Repro.test.tsregisters a${...}entity, matching the reporter's plugin, and covers the three broken shapes plus two controls that must keep working: a match that does not end the node, and a match that only completes inside the sibling (which must still be left alone).Before
After
Unit tests only — this is a text-transform path with no e2e coverage of its own.