Repository navigation
Conversation
…he quote A tab right after `>` is partly quote padding: CommonMark consumes one column of it and keeps the rest as code spaces. shiftLine kept that tab as a byte, so Tab / Shift-Tab / Enter-split changed the quoted code literal whenever the tab's width changed. It now keeps its width like any other prefix tab. Tests judge code by commonmark.js's literal, which lezer's CodeText range cannot show.
… stays code The closing-fence test is a threshold (4+ columns past the container's content), so expanding every width-changing tab on such a line was more than needed: inside a quote, Shift-Tab then Tab turned a code tab into spaces for good. Expand it only when keeping the byte would drop the line below the threshold.
CommonMark strips the fence indent relative to the container content, so inside a quote a tab overlapping that indent is measured too. Read both the fence indent and the closing-run threshold from the container's content column on each line.
…ner chain A list inside a quote can have its `>` at a different column on each line, so the item's absolute content column from its marker line is stale on other lines. Read each container's content column per line: a quote past its own `>`, an item as far past its parent's content as on its marker line. Also pin that the quoted fence stays with its item after an Enter split and a follower renumber.
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
List Tab / Shift-Tab (and the Enter split) changed the code literal of a quoted fence when a code line's tab sat right after
>. That tab is partly quote padding: CommonMark consumes one column of it and keeps the rest of its width as code spaces, so it must keep its width, not its byte.Changes
shiftLine(src/webview/cm/list/list-transform.ts): drop the special case that kept a tab right after aQuoteMarkas a byte. The tab now goes through the ordinary prefix path (expanded only when its width would change). Code tabs past the padding still stay bytes via the existingCodeText/inMeasuredIndentrule.inMeasuredIndentreads its columns from the fence container's content column on each line (newcontainerContentColumn, read per line through the container chain: Blockquote = after its own>+ 1 padding column, ListItem = as far past its parent's content as on its marker line, so a list inside a quote with a misaligned>is measured correctly). The fence indent is measured inside quotes too, as the opener's indent relative to its quote content (before, "never inside a quote" changed the literal when the fence was indented).inMeasuredIndent: the closing-fence-run rule is now a threshold check. A tab on a code line that is a fence run keeps its width only when keeping its byte would leave the run under 4 columns past its container's content (Blockquote: after>+ 1 padding column; ListItem: item content column). Before, every width-changing tab there was expanded, which (once the quote-padding tab no longer short-circuited) turned a code tab into spaces irreversibly on Shift-Tab → Tab (found in review).codeLiterals(test/webview/helpers/list-structure.ts): commonmark.jscode_block.literalfor every code block. lezer'sCodeTextrange cannot show a partly consumed tab, so it is the oracle for code preservation.cm-list-indent-keymap.test.ts: Tab and Shift-Tab pinned against that oracle for>\tx,>\t\tx, and the fix: keep a fence-like code line inside an unclosed fence on list Tab / Shift-Tab #582 shape 1 (> \tx, switched from the CodeText slice pin).cm-list-continuation-keymap.test.ts: the fix(list): keep nested children under the new item when Enter splits a list item #506 Enter-split pin (>\t\treturn) switched to the same oracle; it was hiding the same bug (literal" \treturn"became" \treturn").Related
>直後の tab が code literal を変えるTest Plan
list-transform.ts(checked in a throwaway worktree), 5 fail — Tab and Shift-Tab for>\tx("x\n"→" x\n"," x\n"→"x\n") and>\t\tx("\tx\n"↔" \tx\n"), plus the Enter split (" \treturn\n"→" \treturn\n"). Shape 1 stays green on both, as fix: keep a fence-like code line inside an unclosed fence on list Tab / Shift-Tab #582 decided.8. first\n9. second\n > ~~~\n >\t\tx…, Enter afterfi): fails onorigin/main(" \tx\n"→" \tx\n"), passes now.Tab widens a quoted fence-run code line's tab when its byte would close the fenceand the existingShift-Tab keeps a fence-like code line of an unclosed fence as code.CodeTextafter each): quoted no-fence-indent and unquoted rows fail onorigin/main; the quoted one-column-fence-indent row fails on the intermediate head 844d0a9, and the two list-inside-quote rows fail on a0533ba. The Enter split / follower tests also pin that the quoted fence stays with10. …(blockOwner). Tab / Shift-Tab table also pins that B still owns the quoted fence (blockOwner).vitest run test/webview/list/1163/1163 pass,pnpm lintandpnpm compileclean at d7140fc.