Skip to content

fix(preview): wrap rendered code blocks and enable text wrap by default - #2056

Merged
l0gicgate merged 2 commits into
lgse:mainfrom
viniciosrab:fix/2055-wrap-preview-code-blocks
Nov 5, 2026
Merged

l0gicgate merged 2 commits into
lgse:mainfrom
viniciosrab:fix/2055-wrap-preview-code-blocks

Conversation

@viniciosrab

Copy link
Copy Markdown
Contributor

Description

Rendered Markdown code blocks never wrapped, even with the preview's wrap toggle on. The document-code text tag forced WrapMode::None, and a tag's wrap mode overrides the view's. This PR drops the forced mode and replaces the first-line indent with left and right margins, so wrapped lines stay inside the code panel. The unwrapped look is unchanged, including code nested in lists.

The code-block copy button no longer covers the end of the first code line. That line reserves room on the right for the button. When wrapping is off, the unwrapped width now counts per-line tag margins, so the button sits past the longest line.

Preview text wrap is now on by default, and a settings file without the key also loads with wrap on. A wrap choice already saved in preferences is kept: existing installs that saved preview_text_wrap = false stay unwrapped until the user toggles it. Docs are updated to match.

Visual evidence

N/A. Agents cannot upload attachments. With wrap on, paragraphs and fenced code blocks (labelled and unlabelled) wrap to the pane width inside the code panel, and the copy button sits clear of the first line. With wrap off, code scrolls horizontally as before.

How to test

  1. Start Strata with fresh preferences and narrow the window so the preview pane is narrow.
  2. Preview a Markdown file that has a long paragraph and a fenced code block with lines longer than the pane.
  3. Hover the code block, then click Toggle word wrap in the preview header twice.

Expected result: Wrapping is on by default. The paragraph and the code block both wrap inside the pane, and the copy button does not hide any code text. Turning wrap off makes the code block scroll horizontally, with the copy button past the end of the longest line. Turning it back on wraps again.

Related issue

Closes #2055

The document-code text tag forced WrapMode::None, overriding the view's
wrap mode, so fenced code blocks never wrapped even with the wrap toggle
on. Drop the forced mode and swap the first-line indent for margins so
wrapped lines stay inside the code panel. Reserve space on the first
code line for the copy button so it no longer covers the text, and
count per-line right margins when sizing unwrapped views.

Preview text wrap is now on by default; saved preferences keep their
choice.

Refs lgse#2055
Use the larger of the view and tag right margins when sizing unwrapped
document lines, so quotes keep their previous inset. Switch the saved
preferences fixture to an explicit false wrap so tests prove a saved
choice survives the new default.

Refs lgse#2055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown and text previews do not wrap to the pane width; code blocks never wrap

2 participants