Markdown editor: Repeated Enter on an empty task item does not exit the list
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
## Description
In the Markdown editor editing mode, Enter correctly continues a task list, but pressing Enter again on the generated empty task does not cleanly exit the task list.
## Reproduction
1. Open the Markdown editor in editing mode.
2. Type `- [ ] First task`.
3. Press Enter. The editor generates the next marker, `- [ ] `.
4. Without typing anything else, press Enter again.
## Expected
Repeated Enter on the generated empty task exits the task list cleanly and predictably, leaving the caret in a normal paragraph.
## Actual
The empty task is not recognized as an empty task-list item on the second Enter. The continuation falls back to an ordinary bullet, producing source equivalent to:
```markdown
- [ ] First task
- [ ]
-
```
This leaves a marker-only checkbox line and an ordinary list marker instead of exiting the list.
## Root Cause
The first Enter re-emits `- [ ] ` from the parsed task item. On the next parse, micromark does not classify marker-only `- [ ] ` as a task: the parser only lifts task state when it sees `taskListCheckValueChecked` or `taskListCheckValueUnchecked` tokens (`parse.ts`, around lines 576-603 and 748-749). Consequently the Enter command sees `[ ]` as item text, treats the item as non-empty, and emits the ordinary `- ` continuation.
The fix should make smart Enter recognize the generated marker-only task source before relying on parsed task classification (or otherwise preserve that transient task context). Add a command-level regression test for the full two-Enter sequence, asserting resulting Markdown and caret position, plus an editing-mode/e2e test if practical.
## Additional Context
This is not a multiline-paste corruption issue. True paste preserves the source; earlier newline-by-newline automation was sending Enter key events rather than performing a paste. The issue is specifically the second Enter on the empty task marker generated by the editor.
Contributor guide
Assessment
This issue has not been assessed yet.