Skip to content

[Bug] Adding a paragraph to a list item keeps the list tight in the editor, but it reopens loose #5297

Closed

Description

@Jocs

Description

When a list item gains a second paragraph while editing, the list keeps rendering tight, but the saved file reopens as a loose list — every item in the list suddenly gets paragraph spacing.

The list's meta.loose is decided when the list block is built (from the parser, or preferLooseListItem when the list is created in the editor), and the mu-tight-list class follows it (packages/muya/src/block/commonMark/bulletList/index.ts, same in orderList / gfm/taskList). Adding a block to an item changes neither, so .mu-tight-list > li > p { margin: 0; padding: 0 } keeps the list compact.

The saved Markdown needs a blank line between the two paragraphs of the item, and in CommonMark that makes the whole list loose, so reopening parses loose: true.

Both existing ways of adding a paragraph to a list item show it. Measured on develop by driving the engine (insertParagraph('after') as the context menu does, and enterHandler / backspaceHandler on the content blocks), then parsing the saved Markdown back:

Starting from - a / - c list meta.loose in the editor saved Markdown meta.loose after reopening
Insert Paragraph After on a, type b false - a\n\n b\n- c\n true
Enter at the end of a, Backspace, type b false - a\n\n b\n- c\n true

Steps to Reproduce

  1. In a new document, type a two-item list: a, c.
  2. Put the caret at the end of a, right-click → Insert Paragraph After, type b.
  3. The list still looks tight: b sits directly under a, and c directly under b.
  4. Save, close and reopen the file.

Expected Behavior

The list's spacing in the editor matches what the saved file reopens as: once an item holds a second paragraph, the list renders loose.

Actual Behavior

The list stays tight in the editor and turns loose only after the file is reopened.

Operating System

macOS

MarkText Version

0.20.0-dev (develop @ bc3e487a)

OS Version

macOS 27.0

Reproducibility

  • I can reliably reproduce this issue

Activity

  1. added
    🐛 bug
    on Sep 10, 2026
  2. added
    🦁 need discuss
    🪲 pri/low
    on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🪲 pri/low🦁 need discuss🐛 bug🔭 area/muya

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions