Repository navigation
fix(editor): align list item continuation lines with the item text - #800
Conversation
A list item whose paragraph spans several source lines rendered only its
first line as a list line. The other lines had no list decoration, so they
started at the paper edge and showed their source indentation:
- First line
wrapped line <- rendered at the left edge, with a leading space
Decorate every line of an item's own paragraphs after the first with
cm-markra-list-continuation. It carries the item's depth and source
visibility, gets the same inline padding as the item text, and hides the
leading indentation while the caret is not on the line, like the list
marker. Nested lists, code blocks and other children keep their own
renderers. Source line breaks still render as line breaks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@leemour is attempting to deploy a commit to the murongg's projects Team on Vercel. A member of the Team first needs to authorize it. |
murongg
left a comment
There was a problem hiding this comment.
Please bound continuation decorations to visible lines before merging. The live Markdown suite passed all 118 tests. Chromium also confirmed alignment for ordinary list items, the out-of-viewport decoration count, and the task-list alignment gap below.
| state.doc.lineAt(paragraph.from).number, | ||
| firstLineNumber + 1, | ||
| ); | ||
| const endLine = state.doc.lineAt(paragraph.to).number; |
There was a problem hiding this comment.
[P2] Limit list continuation decorations to the visible ranges. The syntax-tree iteration is viewport-scoped, but this inner loop walks through the entire paragraph as soon as the list item intersects the viewport. A synthetic 12,000-line item created 12,000 continuation decorations with only 44 continuation lines in the visible range. Please intersect the paragraph with each visible range before decorating and test a long item as well as disjoint visible ranges around a fold.
There was a problem hiding this comment.
Fixed in 6da66fc. The loop now intersects each paragraph with every visible range before walking its lines, so a long item only gets decorations for what is actually drawn. Added a test with a 40-line item and two disjoint visible ranges
| firstLineNumber: number, | ||
| ) => { | ||
| const depth = String(markraListDepth(item)); | ||
| for (const paragraph of item.getChildren("Paragraph")) { |
There was a problem hiding this comment.
[P3] Align continuation text in task items. With - [ ] Task first followed by an indented task next, the first paragraph is represented by a Task node, so this loop skips its continuation. A later plain paragraph gets the regular list indent but still starts to the left of the text after the checkbox. Please cover task continuations and align them with the item text, including the checkbox space.
There was a problem hiding this comment.
Good catch, the first paragraph is a Task node so the loop never saw it. Fixed in 6da66fc - Task children are walked too, and task continuations get the checkbox width on top of the list indent. The test covers both the first paragraph and a later one
…k text Review follow-up for the list continuation decorations. The ListItem node is decorated once, but the continuation loop walked the whole paragraph as soon as the item touched the viewport. A 12,000-line item produced 12,000 line decorations for ~40 visible lines. Intersect each paragraph with every visible range before walking its lines, so disjoint ranges around a fold are covered and nothing outside them is decorated. A task item's first paragraph is a Task node, not a Paragraph, so its continuation lines were skipped. Later paragraphs got the plain list indent and started left of the text after the checkbox. Walk Task children too, mark task continuations with data-list-kind="task" when checkboxes are rendered, and pad them by the checkbox width plus its end margin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Fixes list items whose text spans several source lines. Only the first line of such an item was decorated as a list line. The following lines started at the paper edge and showed their source indentation as a leading space:
Source line breaks still render as line breaks, as they do in paragraphs. Only the alignment changes.
Changes
packages/editor/src/codemirror/preview.ts: for eachListItem, every line of its directParagraphchildren after the item's first line gets acm-markra-list-continuationline decoration with the item'sdata-list-depthanddata-markra-list-source. This covers indented continuation lines, lazy continuation lines and later paragraphs of a loose item. While the caret isn't on the line, the leading indentation is hidden withpushHiddenRange, as the list marker's indentation is. Nested lists, fenced code and other children keep their own renderers. Lines are picked from the syntax tree, not by matching text.packages/app/src/styles.css: the new class joins the existing depth-offset and hidden-source padding rules, so continuation text starts where the item text starts at every depth. It doesn't get the::beforemarker or the sibling spacing rules ofcm-markra-list-item.packages/editor/src/codemirror/live-markdown.test.ts: tests for alignment at depth 0 and 1, ordered and lazy lines, nested lists and code blocks left alone, the same decorations after recreation, the indentation shown while the caret is on the line, and the document left unchanged.Behavior
Because the indentation is shown while the caret is on the line, Backspace at the start of the text deletes one visible space. It never deletes hidden text. Desktop and web behave the same.
Verification
pnpm --filter @markra/editor test: 688 passed, 1 failed.code-block.test.ts > opens, zooms, pans, and resets an enlarged Mermaid previewtimed out at 5000 ms during the full run. Run on its own, it passes both on this branch and onv2without the change.pnpm --filter @markra/editor buildandtypecheck:testpassedpnpm --filter @markra/app testpassed, 141 files and 1666 testspnpm --filter @markra/app typecheck:testandbuildpassedapps/webin Chrome, with the before and after screenshots above. Each continuation line's computedpadding-inline-startmatches the item line (22.4px at depth 0). I'll also check it in a Linux desktop build.Risks
I worked on this together with Claude Code.
🤖 Generated with Claude Code