Skip to content

Preserve TUI markdown list spacing after code blocks#19706

Merged
etraut-openai merged 2 commits intomainfrom
etraut/markdown-extra-line
Apr 27, 2026
Merged

Preserve TUI markdown list spacing after code blocks#19706
etraut-openai merged 2 commits intomainfrom
etraut/markdown-extra-line

Conversation

@etraut-openai
Copy link
Copy Markdown
Collaborator

@etraut-openai etraut-openai commented Apr 26, 2026

Why

Fixes #19702.

The TUI markdown renderer could visually attach the next list marker to a fenced code block inside the previous list item, even when the source markdown included a blank line before the next item. That made block-heavy loose lists harder to read, while the desired behavior is still to keep simple lists compact.

What changed

  • Track whether the current rendered list item contains a code block.
  • Preserve one blank separator before the following list marker only when the previous item contained a code block.
  • Add regression coverage for both paths: code-block list items keep the separator, and simple loose list items stay compact.

Verification

  • cargo test -p codex-tui markdown_render

I also manually verified that the bug exists before and is fixed after.

Before

Screenshot 2026-04-26 at 1 19 01 PM

After

Screenshot 2026-04-26 at 1 18 54 PM

Copy link
Copy Markdown
Contributor

@fcoury-oai fcoury-oai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea to use the presented solution to catch other edge cases.

Comment thread codex-rs/tui/src/markdown_render.rs Outdated
Fixes follow-up from PR review on #19706 for issue #19702.
@etraut-openai etraut-openai enabled auto-merge (squash) April 27, 2026 20:40
@etraut-openai etraut-openai disabled auto-merge April 27, 2026 20:40
@etraut-openai etraut-openai merged commit 52c06b8 into main Apr 27, 2026
25 checks passed
@etraut-openai etraut-openai deleted the etraut/markdown-extra-line branch April 27, 2026 20:40
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TUI markdown renderer collapses loose list spacing after code blocks

2 participants