Repository navigation
fix: keep a quoted code block's indentation visible when its quote marks hide - #592
Merged
Merged
Conversation
…ab in quoted code
… share the HIDE end with the list hang
…lve the quote level locally
…and cache it per tree
… without the overlay climb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 1rendered flush withdef 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:quoteMarkHideEndis 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 aFencedCodeopener, body or closing fence, or an indentedCodeBlock), 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:blockquotePrefixColsusesquoteMarkHideEnd, 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).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 thatblockquotePrefixColsequals what blockquote-reveal actually hides.Related
Test Plan
return 1rendered 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.> quote,>\tquote) stay green;pnpm vitest run test/webview5739/5739.pnpm compileandpnpm lintgreen; on the first head, the full vitest unit (8145/8145) and browser (146/146) suites passed.pnpm teston the first head: 138/139. The one failure isstatus-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.> \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.tsKnown 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.