Skip to content

feat(editor): wrap markdown lines on concealed text - #429

Merged
fcoury merged 3 commits into
mainfrom
explore/conceal-aware-wrap
Nov 2, 2026
Merged

fcoury merged 3 commits into
mainfrom
explore/conceal-aware-wrap

Conversation

@fcoury

@fcoury fcoury commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Markdown paragraphs were still measured with the raw line, so hidden link targets and emphasis markers consumed wrap columns the user could not see. Link-heavy text wrapped too early, and gj/gk landed inside syntax that was not on screen.

This adds a line concealment map for inline Markdown and uses it for wrap width, painting, mouse hit-testing, search highlights, and screen-line motion. Table grids keep their existing projection. The buffer stays the raw document: insert, visual, search, and operator-pending modes reveal the cursor line, and stepping into a concealed span reveals that line so the cell under the cursor is the byte that will be edited.

:markdown-conceal toggles the behavior in the current split. markdown_conceal defaults to on for Markdown buffers while wrap is on. Code fences, escapes, and link reference definitions stay visible.

Paragraph wrapped on visible link labels

gj on a wrapped row, source column past the hidden URLs

Same paragraph with conceal off, URLs consuming wrap rows

Cursor on the link bracket reveals the raw destination

https://github.com/codersauce/red/blob/explore/conceal-aware-wrap-media/conceal_aware_wrap.mp4

Conceal-aware wrap demo

How to Test

git fetch origin explore/conceal-aware-wrap
git checkout explore/conceal-aware-wrap
cargo build

Save this as notes.md:

Read the [editor guide](https://example.com/red/docs/guides/conceal-aware-wrapping/long-path) and the [movement notes](https://example.com/red/docs/reference/screen-line-motion/gj-and-gk) before editing this paragraph so the links stay on the rows you can see.

Open it in a narrow terminal: cargo run -- notes.md

markdown_conceal defaults to on (:markdown-conceal toggles the current split). With wrap on:

  • The paragraph shows editor guide and movement notes and wraps on those words. The URLs are not on screen.
  • gj and gk move over those visible rows. The status column jumps across the hidden destinations.
  • f[ lands on [ and the line's raw syntax appears. x deletes that source bracket; u restores it. Buffer text otherwise stays unchanged.
  • :markdown-conceal shows the URLs and the extra wrap rows. Run it again to conceal them.
  • In insert mode only the cursor line is raw; the next Markdown line stays concealed.
  • A non-Markdown buffer keeps the brackets and URLs.
cargo test --lib markdown_conceal display_layout::tests::concealed conceal_aware_wrap
cargo clippy --all-targets --all-features -- -D warnings
Open in Web Open in Cursor 

Hidden link targets and emphasis markers no longer consume wrap
columns, and screen-line motion follows the visible rows.
@fcoury

fcoury commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T21:12:09.848951Z 36c7f45 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 36c7f45c11

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/editor/rendering.rs Resolved
Search ranges now use the same visible-column map as wrapped text,
and the conceal toggle stays out of the command executor's stack frame.
The detach shell test was overflowing the 2MB thread once command
execution sat next to that future. Box the client and server futures.
@fcoury
fcoury marked this pull request as ready for review November 2, 2026 21:45
@fcoury
fcoury merged commit 6562c58 into main Nov 2, 2026
16 checks passed
@fcoury
fcoury deleted the explore/conceal-aware-wrap branch November 2, 2026 21:45
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