Repository navigation
Conversation
…tcut `registerMarkdownShortcuts` only runs its transformers when the update looks like a single typed character, which it checks by comparing the anchor offset against the previous anchor offset. A node transform can split or merge the leaves around the caret in the same update, which moves the anchor into a different node and makes the two raw offsets incomparable. Typing `##` in front of existing text is exactly that case: the hashtag entity matches `#Welcome` inside `##Welcome`, so the caret ends up at offset 1 of the hashtag node. Typing the space then breaks the hashtag and merges everything back into one text node at offset 3, which reads as a jump of two characters, and the heading transformer never runs. Rebase both offsets on the parent element before comparing them. When the leaves around the caret are unchanged this adds the same constant on both sides, so the existing comparison is unaffected.
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 8, 2026 03:28
|
@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.
Typing
##in front of existing text leaves the literal##in a paragraph instead of producing anh2.registerMarkdownShortcutsonly runs its transformers when the update looks like a single typed character, which it checks by comparing the anchor offset against the previous anchor offset. A node transform can split or merge the leaves around the caret inside that same update, which moves the anchor into a different node and makes the two raw offsets incomparable.##Welcomeis exactly that: the hashtag entity claims#Welcome, so the caret ends up at offset 1 of the hashtag node. Typing the space breaks the hashtag and merges everything back into one text node at offset 3, which reads as a two-character jump, and the heading transformer never runs.#works;##through######do not. That matches the reporter's own analysis in the thread.Rebase both offsets on the parent element before comparing them. When the leaves around the caret are unchanged this adds the same constant to both sides, so the existing comparison is unaffected — it only changes the case where a node transform moved the caret into a different leaf.
Adds a headless unit test covering
#through######with the hashtag entity registered, and a playground e2e for the reported repro. The#case passes either way and is a control.Fixes #5366