Skip to content

fix(workbench): keep active and incomplete Markdown syntax visible - #7117

Merged
Astro-Han merged 3 commits into
rust-previewfrom
fix/composer-markdown-conceal
Nov 22, 2026
Merged

Astro-Han merged 3 commits into
rust-previewfrom
fix/composer-markdown-conceal

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Typing > or ``` in the composer (and Markdown file editor) immediately hid the typed characters because:

  1. Presentation::decorations checked !owner.contains(&pos) against selection().head(). That half-open range excluded owner.end, which is where the caret sits right after typing.
  2. code_block() concealed the opening fence line even for unclosed or empty fenced code blocks (hiding and language info strings likerust while typing or after moving focus away), treated 4-space indented literal fence lines as closing/opening fences, and Reader::visit registered incomplete or empty Mermaid blocks for diagram replacement before validating the fence. quote() also concealed > on empty blockquote lines (turning >, > , or >>> blank).

This keeps #6951's existing preview design intact while fixing both causes:

  • Switch syntax reveal (and Mermaid diagram reveal) to closed-range containment against selection().head() (owner.start <= pos && pos <= owner.end), keeping active syntax visible at trailing carets without expanding the whole document on Cmd+A, and removing the + 1 end-bound workaround in list_marker.
  • Only conceal fenced code block delimiters (and register Mermaid diagrams) when both fences satisfy CommonMark's 0..=3 leading-space rule, a matching closing fence exists, and parsed Code.value has non-empty content.
  • Only conceal blockquote > prefixes on lines that have non-empty content after the quote markers.

Refs #6951

Verification

  • Ran cargo nextest run -p maka-workbench -E 'test(composer_input::markdown)' — 4 passed (covering trailing-caret reveal, AllSelection non-expansion, empty quotes, unclosed/empty/4-space-indented fences, 3-space valid fences, and Mermaid diagram gating).
  • Ran rustfmt --edition 2024 --check products/maka/workbench/src/composer_input/markdown.rs — passed.
  • Ran cargo clippy -p maka-workbench --all-targets --no-deps -- -D warnings — 0 warnings on the changed lines (pre-existing collapsible_if / items_after_test_module warnings on untouched lines in quick_tools.rs and markdown.rs:392).
  • Did not run full desktop UI integration tests locally; relying on CI (native-macos / native-windows) for the desktop composer suite.

AI use

Select exactly one:

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Antigravity (Gemini) diagnosed the root cause, implemented the fix and regression tests in products/maka/workbench/src/composer_input/markdown.rs, and ran local verification; GPT-6.2-Sol (High) performed an adversarial review that surfaced the 4-space fence and Mermaid gating edge cases.

Checklist

  • Tests cover the change and fail without it
  • Format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Use closed-range selection intersection when deciding whether to conceal Markdown syntax in the composer and file editor, so markers stay visible while typing at a node's end or selecting across it. Also skip concealing empty blockquote markers and unclosed or empty fenced code blocks so unfinished '>' and '```' input never disappears.

Generated-by: Antigravity (Gemini)
…rams on complete fences

Limit fenced code block detection to CommonMark's 0..=3 leading spaces so 4-space indented code lines are never mistaken for fences, check non-empty content via the parsed `Code.value`, and require the same complete-fence check before registering Mermaid diagrams in file preview.

Generated-by: Antigravity (Gemini)
… select-all

Keep syntax reveal keyed to `selection().head()` with closed bounds (`owner.start <= pos && pos <= owner.end`) instead of intersecting the full selection range. Expanding every formatted span covered by `AllSelection` shifts horizontal layout during Cmd+A, breaking click hit-testing and caret geometry in desktop composer tests.

Generated-by: Antigravity (Gemini)
@Astro-Han
Astro-Han marked this pull request as ready for review November 22, 2026 02:57
@Astro-Han
Astro-Han merged commit 9544846 into rust-preview Nov 22, 2026
15 of 19 checks passed
@Astro-Han
Astro-Han deleted the fix/composer-markdown-conceal branch November 22, 2026 02:57
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