Skip to content

fix: keep a quoted code block's indentation visible when its quote marks hide - #592

Merged
mtskf merged 11 commits into
mainfrom
fix/quote-code-indent-hidden
Dec 4, 2026
Merged

mtskf merged 11 commits into
mainfrom
fix/quote-code-indent-hidden

Conversation

@mtskf

@mtskf mtskf commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Summary

Inside a blockquote, the HIDE decoration on > swallowed every space after the mark, so a quoted fenced or indented code block lost its indentation whenever the caret was off the line (> return 1 rendered flush with def f():). On a row of quoted code, the quote now hides only its delimiter, so code and fence indentation (and a list's padding) render as they do unquoted.

Changes

  • blockquote-reveal.ts: quoteMarkHideEnd is the single source of truth for where a quote mark's HIDE ends. On prose rows it absorbs all structural whitespace (unchanged). On a code row (the line end resolves into a FencedCode opener, body or closing fence, or an indented CodeBlock), the innermost mark hides only the delimiter Lezer consumed (delimiterEnd): > plus one space, or on a continuation line one space or tab. The opener takes only a space, so a tab after it is the block's own indentation. An outer mark hides the gap up to the next > except the continuation padding of any list between the two quotes (visible, as it is unquoted; measured in columns with Lezer's 4-column tab stops, from the outer quote's delimiter to the innermost item's content on that item's own marker row, and cached per syntax tree so an off-screen opener is read once per document version). Each code row's hide ends are worked out once per tree (linear in its prefix), so deep nesting and repeated rebuilds stay cheap; the optional indent before a > is insignificant and hides. The quote level is resolved from the row's own prefix, so the cost stays bounded by the viewport, not the block size.
  • list-hang-indent.ts: blockquotePrefixCols uses quoteMarkHideEnd, so the soft-wrap hang subtracts exactly the columns that are hidden, including on a quoted list marker row whose content is indented code (> - code).
  • Tests (cm-decoration-blockquote.test.ts, 16 new) assert the rendered text (doc minus HIDE ranges). Several compare against the same document with the outer quote stripped. Cases: fenced, indented, nested quotes (gap absorbed), a list between nested quotes (padding kept, fenced and indented; surplus indent before the inner > hidden; a tab after an ordered marker and mixed-whitespace continuation rows; nested list padding across a tab; bounded and cached reads of the off-screen list opener; linear work on a deeply nested row; a bounded read on a deeply indented single-quote row), opener tab, continuation tab, indented-fence alignment, fenced code in a quoted list, and, through the full reveal registry with the caret in the body, fence columns for equal and unequal fence indentation. cm-decoration-list-hang.test.ts (2 new) pins the code-row prefix width and that blockquotePrefixCols equals what blockquote-reveal actually hides.

Related

  • TODO: REV-20261203-14 — quote 内の fenced / indented code のインデントが、caret が行に無いあいだ表示から消える

Test Plan

  • Reproduce-first: the fenced and indented tests failed on main (absorb-all HIDE: return 1 rendered with no indent; def f(): lost its 4 code-block spaces) and pass now. The registry fence-column test also fails on main's implementation. The nested-quote, list-between-quotes and list-hang tests each failed on an intermediate head of this PR (revert-checked) and pass now.
  • Existing prose-absorption pins (> quote, >\tquote) stay green; pnpm vitest run test/webview 5739/5739.
  • pnpm compile and pnpm lint green; on the first head, the full vitest unit (8145/8145) and browser (146/146) suites passed.
  • E2E is not required (webview-only decoration change, no host or protocol path touched), but it ran once as part of pnpm test on the first head: 138/139. The one failure is status-bar-active-edge "refreshes the count slot text when the document changes", the known load flake tracked in TODO.md (host-side word count after an external write, a document with no blockquote). Reruns at that head: 1 more fail, then a pass (139/139). One run with the change reverted also passed.
  • Known limitation: a TAB that stays visible after a hidden quote prefix renders on the browser's rendered tab grid, so it can sit off by up to one tab stop. This applies to the code's own tab indentation (quoted fenced > \treturn 1) and to tab-written list padding between nested quotes (> \t> code). On main those TABs were hidden together with the quote mark, so the indentation was lost rather than re-snapped; this PR makes them visible, at most one tab stop off. Only the list hang's tab residual (list-hang-indent.ts Known limitations (b)) pre-exists on main. Space-indented rows render exactly. Accepted as a known limitation for this PR (user go, delivery exception); tracked as a parked TODO.

@mtskf
mtskf merged commit 1199772 into main Dec 4, 2026
2 checks passed
@mtskf
mtskf deleted the fix/quote-code-indent-hidden branch December 4, 2026 04:11
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