Skip to content

fix(muya): keep a Tab-indented list item out of a sublist of the other kind (#5349) - #5354

Merged
Jocs merged 2 commits into
developfrom
fix/5349-indent-list-kind
Sep 14, 2026
Merged

Jocs merged 2 commits into
developfrom
fix/5349-indent-list-kind

Conversation

@Jocs

@Jocs Jocs commented Sep 14, 2026

Copy link
Copy Markdown
Member

Closes #5349

Summary

Tab nests a list item under the previous item. When that item already ended with a sublist, ParagraphContent._indentListItem() appended the new item to it whenever it was any ul/ol, without checking the item kind. A task item landed in a bullet or ordered list, or a plain item in a task list. Neither list may hold that kind, later Enter kept adding items of the wrong kind, and reopening the saved markdown gave a different structure. This is the indent direction of #5341 (Shift+Tab, fixed by #5348).

Two commits:

  1. fix(muya): give an indented item a list of its own kind. Join the previous item's trailing sublist only when it holds the item's kind; otherwise create a new list of the item's own kind after that sublist, which is the structure the parser builds for the saved markdown. Same-kind sublists and items with no trailing sublist behave as before.
  2. fix(muya): match the looseness of a same-marker sublist when indenting. A list created next to a sublist of the other kind that uses the same marker is still the same markdown list, so it takes that sublist's looseness. Without this, a loose outer list with a tight sublist reopened differently.

Before / after

Real Chrome (muya e2e host): click at the end of c, Tab, then type z, Enter, n. Then reopen the saved markdown, and separately undo the Tab.

Document develop this PR
- [ ] a / - b / - [ ] c a{ bullet-list{ b, task c, task n } }, structure changes on reopen a{ bullet-list{ b }, task-list{ c, n } }, same on reopen
- a / - [ ] b / - c a{ task-list{ b, item c, item n } }, changes on reopen a{ task-list{ b }, bullet-list{ c, n } }, same
1. a / - [ ] b / 2. c a{ task-list{ b, item c } }, reopens with c as a bullet a{ task-list{ b }, order-list{ c, n } }, same
- [ ] a / - b / - [x] c checked task item inside the bullet list task-list{ [x]c, n }, checked state kept
- a / - b / - c (same kind) appended to the sublist unchanged
- [ ] a / - [ ] c (no sublist) new task sublist unchanged

No renderer errors and undo restores the document in every case, on both versions. In the built desktop app, the rendered lists after Tab go from mu-bullet-list[b, task c] to mu-bullet-list[b] + mu-task-list[c], and from mu-task-list[b, item c] to mu-task-list[b] + mu-bullet-list[c].

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • New tests added in paragraphContent/__tests__/indentListKind.spec.ts. Each case asserts every list holds only its own item kind and that the state equals what reopening the serialized markdown builds:
    • task item into a bullet sublist; plain item into a task sublist; ordered item next to a task sublist; checked state + caret, and a second Tab joining the new list; loose lists
    • controls: same-kind sublist, no sublist, undo
    • on develop: the 5 different-kind cases fail and the 3 controls pass. The loose-list case also fails with only the first commit's change (checked by removing the looseness rule).
  • muya: vitest run 229 files / 1622 tests pass; lint (no new warnings), lint:types, check-circular pass.
  • Real Chrome (muya e2e host) and the built desktop app (build:unpack + Playwright/Electron): the table above.
  • Manually tested on: macOS

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KGKDSxyPk9WxU2h5DgPcWn

Jocs and others added 2 commits September 14, 2026 20:16
Tab nests an item under the previous item and appended it to that item's
trailing sublist whenever the sublist was any list, so a task item landed in
a bullet or ordered list and a plain item in a task list. Neither list may
hold that kind, and reopening the saved markdown gave a different structure.

Join the trailing sublist only when it holds the item's kind; otherwise give
the item a new list of its own kind after that sublist, the structure the
parser builds for the saved markdown.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KGKDSxyPk9WxU2h5DgPcWn
A list created next to a sublist of the other item kind that uses the same
marker is still the same markdown list. It copied the looseness of the list
the item came from, so with a loose outer list and a tight sublist the
serialized markdown reopened with a different structure. Take the looseness
of that sublist instead.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KGKDSxyPk9WxU2h5DgPcWn
@Jocs
Jocs merged commit 4e354c0 into develop Sep 14, 2026
7 checks passed
@Jocs
Jocs deleted the fix/5349-indent-list-kind branch September 14, 2026 13:04
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.

[Bug] Tab on a list item appends it to the previous item's sublist even when that sublist holds the other item kind

1 participant