Skip to content

fix(muya): split the list when outdenting a task item into a plain list (#5341) - #5348

Merged
Jocs merged 2 commits into
developfrom
fix/5341-task-item-outdent-split
Sep 14, 2026
Merged

Jocs merged 2 commits into
developfrom
fix/5341-task-item-outdent-split

Conversation

@Jocs

@Jocs Jocs commented Sep 14, 2026

Copy link
Copy Markdown
Member

Closes #5341

Summary

Shift+Tab on a task item nested in a bullet or ordered list moved it into the outer list as a task-list-item, which only a task-list may hold (and the reverse for a plain item nested in a task list). The editor showed a plain bullet next to checkbox items, and reopening the saved markdown produced a different document — for an ordered outer list the checkbox was lost entirely.

Two commits:

1. fix(muya): keep adjacent tight lists with the same marker tight

The parser splits one markdown list into a bullet list and a task list where its items switch between plain and task (utils/marked/compatibleTaskList.ts). The serializer wrote a blank line between those adjacent lists, which are still one list in markdown, so a tight - a\n- [ ] b came back loose (- a\n\n- [ ] b) after one save and reopen — even without any outdent. The blank line is now skipped when the previous block is a tight list with the same marker/delimiter and this list is tight too. Loose lists and lists with a different marker are serialized as before.

This is what lets the outdent result below round-trip unchanged.

2. fix(muya): split the list when outdenting an item of the other kind (#5341)

_unindentListItem() now inserts the outdented item through _insertOutdentedListItem():

  • Same item kind (e.g. a bullet item inside an ordered list): inserted after the parent item, as before.
  • Different kind: the outer list is split after the parent item. The outdented item goes into a new list of its own kind (checked state kept); the items that followed the parent item go into a list of the outer kind after it, continuing an ordered list's start. With the same marker, the new list shares the outer list's looseness, since it is still part of that markdown list.
  • A list of the item's kind with the same marker already follows (and there is no tail): the item joins it. The issue listed this as an open question; it is required rather than optional, because the parser merges those lists anyway (- a\n- [ ] b\n- [ ] x reopens as bullet(a) + task(b, x)), so creating a separate list would change on reopen. Ordered lists are not merged, since joining would need the following list's start rewritten.
  • The fix: #4899 keep trailing content out of the child list when outdenting a list item #4913 behaviour is kept: remaining sibling items and trailing content still end up under the outdented item.

The result is the structure the parser builds for the saved markdown.

Real Chrome (muya e2e host, real keys: click at the end of b, Shift+Tab; then reopen the saved markdown and undo):

Input develop after Shift+Tab develop: reopen This PR after Shift+Tab This PR: reopen
- a / - [ ] b bullet-list{a, task b} ✗ - a\n\n- [ ] b… (changed) bullet-list{a} task-list{b} identical
- a / - [x] b / - c bullet-list{a, task b, c} ✗ changed bullet{a} task{[x] b} bullet{c} identical
1. a / - [ ] b / 2. c order-list{a, task b, c} ✗, saved as 2. [ ] b checkbox lost (2. b) order(1){a} task{b} order(2){c} identical
- [ ] a / - b task-list{a, item b} ✗ changed task{a} bullet{b} identical
- a / - [ ] b / - [ ] x bullet{a, task b} task{x} ✗ changed bullet{a} task{b, x} identical
- a / - [ ] b / - [ ] d / c (+ ↓ Home Backspace) bullet{a, task b{…}} ✗ state changed bullet{a} task{b{task-list{d}, c}} identical

✗ = a list holding an item kind it doesn't allow. Undo returned to the original document and no renderer errors were thrown in every case, on both develop and this PR.

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
    • state/__tests__/listSerialization.spec.ts: tight bullet→task, task→bullet→task, and nested tight split lists round-trip unchanged (3 cases fail on develop); loose split lists and different markers unchanged.
    • paragraphContent/__tests__/unindentListKindSplit.spec.ts: basic split, checked state and caret, tail items, ordered numbering, reverse case, joining a following task list, different marker, siblings + trailing content, same-kind control, undo. Every structural case asserts that each list holds only its own item kind and that the state equals the reparsed state of its markdown (8 cases fail on develop; the same-kind and undo controls pass on both).
  • muya: vitest run 226 files / 1587 tests pass; test:spec 1347 pass; lint (no new warnings), lint:types, check-circular pass.
  • Real Chrome against the muya e2e host with real keys (table above), on this branch and on develop's versions of the two changed files.
  • 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 15:47
The parser splits one markdown list into a bullet list and a task list where
its items switch between plain and task. The serializer wrote a blank line
between those adjacent lists, which is still one list in markdown, so a tight
`- a\n- [ ] b` came back loose (`- a\n\n- [ ] b`) after one save and reopen.

Skip the blank line when the previous block is a tight list with the same
marker or delimiter and this list is tight too. Loose lists and lists with a
different marker are serialized as before.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KGKDSxyPk9WxU2h5DgPcWn
…5341)

Shift+Tab on a task item nested in a bullet or ordered list moved it into
the outer list as a `task-list-item`, which only a `task-list` may hold (and
the reverse for a plain item nested in a task list). The editor showed a
plain bullet next to checkbox items, and reopening the saved markdown split
the list differently.

Split the outer list after the parent item instead: the outdented item goes
into a new list of its own kind, keeping its checked state, and the items
that followed the parent item go into a list of the outer kind after it,
continuing an ordered list's numbering. When a list of the item's kind with
the same marker already follows, the item joins it. This is the structure
the parser builds for the saved markdown, so the document is unchanged
across a reopen. Items of the same kind are inserted into the outer list as
before.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01KGKDSxyPk9WxU2h5DgPcWn
@Jocs
Jocs merged commit 80cd55c into develop Sep 14, 2026
7 checks passed
@Jocs
Jocs deleted the fix/5341-task-item-outdent-split branch September 14, 2026 08:19
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] Shift+Tab on a nested task list item puts a task item inside the parent bullet list

1 participant