Skip to content

fix(help): render a code block whose fence is never closed - #4183

Merged
max-sixty merged 1 commit into
mainfrom
nightly/clean-35315762380
Sep 18, 2026
Merged

max-sixty merged 1 commit into
mainfrom
nightly/clean-35315762380

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

An unterminated code fence in a PR description or comment silently swallowed
the rest of the body in the switch picker's preview panes.

md_help::render_markdown collects fenced lines and renders them when it sees
the closing fence. With no closing fence, the loop ended with the lines still
in the buffer and nothing appended — so everything from the opening fence to
the end of the input disappeared. Help pages are authored and balanced, so this
never showed there; the pr and comments panes reach the same function through
render_markdown_flush with markdown the forge hands us verbatim
(picker::pr_pane::description, picker::pr_pane::markdown_in_gutter).

The block rendering moves into render_code_block, called both at the closing
fence and once at end of input when a block is still open. An unterminated
block now renders exactly as the same lines would with a closing fence — same
dim, same gutter, same language handling — so nothing else about the output
moves.

Two regression tests, one per render context (flush for the panes, gutter for
help). Both fail on main: the rendered output stops at before and the
fenced lines are gone.

Verification
  • cargo test --bins md_help::tests::test_unterminated — passes with the fix,
    fails with the end-of-input flush reverted.
  • cargo test --bins — one unrelated failure,
    commands::step::promote::tests::test_copy_and_remove_drops_a_non_regular_file,
    which binds a Unix socket; the tend sandbox denies socket(AF_UNIX, …), so
    it fails there regardless of this change and passes in CI.
  • cargo test --test integration -- test_help test_docs_are_in_sync — 57
    passed, so no rendered help or doc-sync snapshot moves.
  • cargo fmt --check, cargo clippy --bins --all-targets — clean.

`render_markdown` collected fenced lines and rendered them only on the
closing fence, so an unterminated fence dropped everything from the fence
to the end of the input. Help pages are authored and balanced, but the
picker's `pr` and comments panes render arbitrary forge markdown through
the same function, where a PR body or comment that opens a fence and
never closes it lost the rest of its text silently.

Extract the block rendering into `render_code_block` and call it both at
the closing fence and once more at end of input when a block is still
open, so an unterminated block renders exactly as the same lines would
with a closing fence.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Sep 18, 2026
@max-sixty
max-sixty merged commit 0c8116a into main Sep 18, 2026
37 of 47 checks passed
@max-sixty
max-sixty deleted the nightly/clean-35315762380 branch September 18, 2026 09:08
@max-sixty max-sixty mentioned this pull request Sep 20, 2026
max-sixty added a commit that referenced this pull request Sep 20, 2026
0.79.0 was prepared and merged in #4181 but never tagged, so it never shipped.
Cargo.toml and Cargo.lock already carry the version, so this reuses it and folds
the thirteen commits that landed since into the same changelog section.

New entries cover the worktree-side rename fixes (#4190, #4191), the per-project
unknown-field warning (#4123), and the unterminated code fence in the picker's
preview (#4183, combined with #4178's column fix).

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants