fix(markdown_parser): fix lazy continuation at nested list marker indent#9776
Conversation
|
Merging this PR will not alter performance
Comparing Footnotes
|
Change `<=` to `<` in `check_continuation_indent` so a line at exactly the nested marker's indent column can lazily continue the nested paragraph per CommonMark §5.2, instead of being incorrectly assigned to the parent item. Emit the available indent as a structural MdContinuationIndent node on the lazy path, matching the sufficient-indent path, so indent spaces appear as MD_INDENT_CHAR rather than MD_TEXTUAL_LITERAL.
a282821 to
06201a2
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe patch changes continuation-indent handling in the Markdown list parser by removing an early break for lazy continuations at the marker column. For the lazy-continuation path ( Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/biome_markdown_parser/src/syntax/list.rs (1)
2080-2087: Drop the now-unreachable guard.Line 2012 already exits on
indent < state.marker_indent, so this branch can no longer fire after the<=→<change. Keeping it here makes the lazy-continuation rules look more complicated than they are.♻️ Suggested tidy-up
- // If the line's indent falls strictly below the nested marker column, - // it belongs to the parent item. Lines at exactly marker_indent may - // still lazily continue the nested paragraph per CommonMark §5.2. - if state.marker_indent > 0 && indent < state.marker_indent { - return ContinuationResult { - action: LoopAction::Break, - restore: VirtualLineRestore::None, - }; - } - // Lazy continuation per CommonMark §5.2🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/biome_markdown_parser/src/syntax/list.rs` around lines 2080 - 2087, Remove the now-unreachable guard that checks "if state.marker_indent > 0 && indent < state.marker_indent" and returns ContinuationResult { action: LoopAction::Break, restore: VirtualLineRestore::None }; since earlier logic already returns when indent < state.marker_indent (see the earlier exit at line ~2012), delete this whole branch from the function (references: state.marker_indent, indent, ContinuationResult, LoopAction::Break, VirtualLineRestore::None) so the lazy-continuation rules are clearer and no dead branch remains.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/biome_markdown_parser/src/syntax/list.rs`:
- Around line 2080-2087: Remove the now-unreachable guard that checks "if
state.marker_indent > 0 && indent < state.marker_indent" and returns
ContinuationResult { action: LoopAction::Break, restore:
VirtualLineRestore::None }; since earlier logic already returns when indent <
state.marker_indent (see the earlier exit at line ~2012), delete this whole
branch from the function (references: state.marker_indent, indent,
ContinuationResult, LoopAction::Break, VirtualLineRestore::None) so the
lazy-continuation rules are clearer and no dead branch remains.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8534c162-6072-47b2-b554-90ecc437b4bb
⛔ Files ignored due to path filters (3)
crates/biome_markdown_parser/tests/md_test_suite/ok/lazy_continuation_at_marker_indent.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_parser/tests/md_test_suite/ok/list_continuation_edge_cases.md.snapis excluded by!**/*.snapand included by**crates/biome_markdown_parser/tests/md_test_suite/ok/list_indentation.md.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (3)
crates/biome_markdown_parser/src/syntax/list.rscrates/biome_markdown_parser/tests/md_test_suite/ok/lazy_continuation_at_marker_indent.mdcrates/biome_markdown_parser/tests/spec_test.rs
Note
This PR was created with AI assistance (Claude Code).
Summary
Two fixes to lazy continuation handling when a line's indent equals the nested list marker column:
<=to<incheck_continuation_indent(list.rs:2083) so the line can reach the lazy continuation check at line 2091 instead of being prematurely assigned to the parent item.MdContinuationIndentemission on the lazy path, matching the sufficient-indent path at line 2052. Without this, the indent spaces were parsed asMD_TEXTUAL_LITERALinstead ofMD_INDENT_CHARinside a structuralMdContinuationIndentnode.Example:
Previously
lazy linewas assigned to the outer item. Now it correctly lazy-continues the nested paragraph per CommonMark §5.2, with the leading spaces represented structurally.Test Plan
tests/md_test_suite/ok/lazy_continuation_at_marker_indent.md— locks in both ownership and structural indent behavior.cargo test -p biome_markdown_parser quick_test— HTML output verified againstcommonmark.jsreference.just test-crate biome_markdown_parser— all passed (79 snapshot tests).just test-markdown-conformance— 652/652.just fjust lDocs
N/A.