fix(mdxish): restore correct end position for fully-consumed nested component blocks#1527
Conversation
|
@coderabbitai review full |
|
✅ Action performedFull review finished. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
💤 Files with no reviewable changes (1)
WalkthroughThe MDX component-block transformer now uses source text from Warning Review ran into problems🔥 ProblemsLinked repositories: Couldn't analyze Linked repositories: Couldn't analyze Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@processor/transform/mdxish/components/mdx-blocks.ts`:
- Around line 231-236: The trailing-content path in mdx-blocks.ts still computes
endPosition with positionEndingAtConsumed, which uses the stripped value and can
undercount original source offsets when blockquote/list prefixes were removed.
Update the branch in the component position mapping logic to account for
original-source coordinates or apply the same prefix-aware adjustment used
elsewhere in the function, using the existing symbols positionEndingAtConsumed,
contentAfterClose, and nodeToSource as guides. Also add a regression test
covering a nested component with trailing sibling content inside a blockquote or
list to verify the closing tag is not truncated.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9eee7e2c-7b4f-4597-a2fe-a709bb5d4130
📒 Files selected for processing (2)
__tests__/transformers/mdx-component-blocks.test.tsprocessor/transform/mdxish/components/mdx-blocks.ts
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
readmeio/ai(manual)readmeio/gitto(manual)readmeio/markdown(manual)readmeio/readme(manual)
This PR was released!🚀 Changes included in v14.10.2 |

🎯 What does this PR do?
Fixes a regression introduced by #1519. This regression is causing test failures for the monorepo update.
positionEndingAtConsumedcomputesend.offsetasstart.offset + value.length, wherevalueis the html node's string content after remark strips blockquote/list-item prefix characters (>, leading spaces, etc.). Inside the original source those prefixes are still present on every continuation line, so the computed offset is too small —nodeToSourceslices the original source too early and the closing tag of any multi-line JSX block is dropped.The fix is narrow:
positionEndingAtConsumedis only needed when there is trailing content after the closing tag (the case #1519 targeted). When the entire html node is consumed, the originalnode.positionis already correct and should be used directly.Before:
<Cards>\n <Card />\n(closing tag dropped)After:
<Cards>\n <Card />\n</Cards>🧪 QA tips
📸 Screenshot or Loom