fix(cli): code-block bg fragments on narrow panels (cli-3.4.1)#58
Merged
fix(cli): code-block bg fragments on narrow panels (cli-3.4.1)#58
Conversation
…(cli-3.4.1) The fenced-code renderer used to pad each line to the longest line of its block and emit it as a single Line, letting `Paragraph::wrap` re-flow on render. Ratatui's word-wrap drops trailing styled whitespace at the wrap point, so when a code line was wider than the document panel the gray background broke into truncated stripes — visibly worst on terminal resizes and on narrow initial layouts (reported via screenshot). Pre-wrap inside markdown_to_lines using a new visual-column-aware hard-wrap helper. Each emitted Line is now bounded by `available_width`, so ratatui never re-wraps it and the gutter background paints uniformly on every visual row. Indentation is preserved (no whitespace trim) and double-wide CJK chars never split mid-glyph. Adds wrap_visual_columns + 7 regression tests covering hard-wrap math, CJK boundary safety, blank-line preservation, and end-to-end pipeline output bounded by panel width. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
devtrail explorebreaking into truncated stripes when the document panel is narrower than the longest code line (visible on terminal resize and certain initial layouts — reported via screenshot).Paragraph::wrapre-flowed it, dropping trailing styled whitespace at the wrap point and leaving visible gaps between content rows.markdown_to_linesusing a new visual-column-aware hard-wrap helper (wrap_visual_columns). Each emitted Line is now bounded byavailable_width, so ratatui never re-wraps it and the gutter background paints uniformly on every visual row.Test plan
cargo test— 123 unit tests + 86 integration tests pass; 7 new regression tests added (wrap_visual_columns_*+code_block_wraps_within_panel_width+code_block_blank_lines_keep_background).cargo build --release— clean build asdevtrail-cli v3.4.1.devtrail exploreon theC4-DIAGRAM-GUIDE.mdfrom the screenshot's narrow window. Code blocks should now have a uniform gray background regardless of resize. Blank lines inside code blocks must stay gray.🤖 Generated with Claude Code