Repository navigation
Conversation
…t into a code block while highlighting `$updateAndRetainSelection` restores the selection by walking the code node's children, which is only meaningful when the selection was inside that code node to begin with. It ran unconditionally for any RangeSelection, so a selection living elsewhere in the document got moved into the code block. `$convertFromMarkdownString` leaves the caret at the start of the document, and the highlight transform then immediately pulled it into the last imported code block — scrolling long documents down to it. Skip the retain/restore when the anchor is not inside the code node being highlighted.
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 8, 2026 01:58
|
@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.
$updateAndRetainSelectionrestores the selection by walking the highlighted code node's children. That is only meaningful when the selection was inside that code node, but it ran for everyRangeSelection, so a selection anywhere else in the document was moved into the code block.$convertFromMarkdownStringleaves the caret at the start of the document (root.selectStart()). The highlight transform then immediately pulled it into the imported code block — and with several code blocks, into the last one, scrolling long documents down to it.The fix skips the retain/restore when the anchor is not inside the code node being highlighted; the highlighting itself still runs. Both the Prism and Shiki highlighters carry the same copy of this function, so both are fixed.
Tests: new unit tests in each package import the exact markdown from the issue and assert the caret stays at the start of the first paragraph, plus a control asserting a caret genuinely inside the code block is still retained across tokenization. Reverting the two product files fails 4 of the 5.
Fixes #6305