Skip to content

fix(cli): code-block bg fragments on narrow panels (cli-3.4.1)#58

Merged
montfort merged 1 commit intomainfrom
fix/code-block-bg-cli-3.4.1
Apr 26, 2026
Merged

fix(cli): code-block bg fragments on narrow panels (cli-3.4.1)#58
montfort merged 1 commit intomainfrom
fix/code-block-bg-cli-3.4.1

Conversation

@montfort
Copy link
Copy Markdown
Contributor

Summary

  • Fix the gray background of fenced code blocks in devtrail explore breaking 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).
  • Root cause: each code line was padded to the block's longest line and emitted as a single styled Line. When that Line exceeded the panel width, ratatui's Paragraph::wrap re-flowed it, dropping trailing styled whitespace at the wrap point and leaving visible gaps between content rows.
  • Fix: pre-wrap inside markdown_to_lines using a new visual-column-aware hard-wrap helper (wrap_visual_columns). 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.
  • UTF-8 / CJK safe (double-wide chars never split mid-glyph). Indentation is preserved (no whitespace trim).
  • Patch bump: cli-3.4.0 → cli-3.4.1.

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 as devtrail-cli v3.4.1.
  • Manual TUI smoke test: open devtrail explore on the C4-DIAGRAM-GUIDE.md from 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.
  • Verify wide-panel rendering (image feat: rebrand to Strange Days Tech + CLI scaffolder + repo restructure #1 in the report) is unchanged: gray bar still ends at the longest content + 4 cols, not full panel width.

🤖 Generated with Claude Code

…(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>
@montfort montfort merged commit eefc54c into main Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant