markdown: Fix markdown copy range resolution#50411
Open
pkondzior wants to merge 1 commit intozed-industries:mainfrom
Open
markdown: Fix markdown copy range resolution#50411pkondzior wants to merge 1 commit intozed-industries:mainfrom
pkondzior wants to merge 1 commit intozed-industries:mainfrom
Conversation
Markdown copy still used raw selection slicing, which could split wrapper syntax and produce malformed output like `bold**`. This change resolves copy ranges from parse-time source spans so selection boundaries stay valid for formatted markdown. Inline code events now retain wrapper ranges, stale-parse fallback is preserved, and regression coverage was added for links, inline code, nested wrappers, and multiline selections. Release Notes: - Fixed markdown copy behavior for formatted selections.
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.
Summary
Markdown copy could break formatting when selection edges landed inside wrapper syntax, producing output like
bold**instead of**bold**. This PR makes copy range resolution span-aware, so copied markdown keeps valid boundaries.Why
The old flow used raw source slicing. That works for plain text but is fragile for formatted markdown. Using parse-time span metadata makes selection-to-source mapping consistent for wrappers like bold, links, and inline code.
What changed
The markdown parser now keeps wrapper bounds for inline code, and markdown copy resolution now runs through source-span normalization and wrapper expansion logic. Copy still falls back to clamped raw selection when parsed source is stale. Tests were expanded across parser, resolver, and markdown integration paths.
Cases covered
](...).Closes #42958
Release Notes: