fix: prevent wrap-text from merging lines before block elements#469
fix: prevent wrap-text from merging lines before block elements#469Enter-tainer wants to merge 1 commit intomasterfrom
Conversation
Summary of ChangesHello @Enter-tainer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a formatting bug in the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request effectively fixes the issue where block-level elements (such as list items, headings, and line comments) were incorrectly merged with preceding text when the wrap-text configuration was enabled. By introducing a symmetric check on the first node of the next line, the reflow logic now correctly identifies when a hard break must be preserved to maintain the semantic structure of the Typst markup. The inclusion of a comprehensive test fixture covering various block elements and multiple column widths ensures the robustness of the fix.
📊 Benchmark Performance Reportgroup base pr
----- ---- --
pretty-ai-comprehensive-showcase 1.00 879.0±13.05µs ? ?/sec 1.00 875.4±31.80µs ? ?/sec
pretty-cetz-manual 1.01 746.7±24.13µs ? ?/sec 1.00 741.4±20.23µs ? ?/sec
pretty-codly 1.01 1748.7±12.65µs ? ?/sec 1.00 1725.7±23.97µs ? ?/sec
pretty-cpe 1.01 11.8±0.10ms ? ?/sec 1.00 11.8±0.07ms ? ?/sec
pretty-deep-nested-args 1.00 16.8±0.29µs ? ?/sec 1.01 17.0±0.11µs ? ?/sec
pretty-fletcher-diagram 1.03 517.6±10.32µs ? ?/sec 1.00 503.6±9.52µs ? ?/sec
pretty-fletcher-draw 1.01 1238.8±20.16µs ? ?/sec 1.00 1224.7±32.06µs ? ?/sec
pretty-tablex 1.01 3.3±0.01ms ? ?/sec 1.00 3.3±0.02ms ? ?/sec
pretty-touying-core 1.01 2.1±0.01ms ? ?/sec 1.00 2.1±0.02ms ? ?/sec
pretty-touying-utils 1.01 1186.3±22.46µs ? ?/sec 1.00 1174.7±16.39µs ? ?/sec
pretty-undergraduate-math 1.02 859.2±11.89µs ? ?/sec 1.00 839.5±13.84µs ? ?/sec📏 Binary Size Comparison
📦 Detailed Crate Size Diff (cargo-bloat)Note: Numbers above are a result of guesswork. They are not 100% correct and never will be. @@ -1,8 +1,8 @@
std 394.6 kB
clap_builder 323.0 kB
-typstyle_core 203.4 kB
+typstyle_core 203.5 kB
clap_complete 126.4 kB
typst_syntax 116.3 kB
similar 73.9 kB
typstyle 40.2 kB
walkdir 19.1 kBGenerated by GitHub Actions on 2026-02-16 11:33:59 UTC |
When `wrap-text` is enabled, `convert_markup_body_reflow()` uses softlines between consecutive markup lines so the pretty printer can re-wrap them. However, it only checked the *last* node of the current line (`should_break_after`) to decide whether a hardline is needed, missing the case where the *next* line starts with a block element (ListItem, EnumItem, TermItem, Heading, or LineComment). This caused nested list items and other block elements to be incorrectly flattened into the preceding line. Add a symmetric check on the first node of the next line so that a hardline is emitted before block elements, preserving the original structure. Closes #468 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
8e31d9d to
b4078b6
Compare
Summary
Fixes #468
When
wrap-textis enabled,convert_markup_body_reflow()uses softlines between consecutive markup lines so the pretty printer can re-wrap them. However, it only checked the last node of the current line (should_break_after) to decide whether a hardline is needed, missing the case where the next line starts with a block element (ListItem, EnumItem, TermItem, Heading, or LineComment).This caused nested list items and other block elements to be incorrectly flattened into the preceding line.
Changes
convert_markup_body_reflow()(+4 lines inmarkup.rs)list-nested-468.typcovering nested lists, enums, terms, headings, and content blocksTest plan
list-nested-468tests: 10/10 passed (4 snapshot + 3 consistency + 3 convergence).snap.newfiles)🤖 Generated with Claude Code