Skip to content

Empty unordered list item reappears after pressing Enter #68

Description

@a-firefly

Summary

When editing an empty unordered list item such as - , pressing Enter briefly removes the list marker as expected, but the marker is then inserted again and the line returns to an empty list item.

This appears to contradict the engine's intended behavior in MarkdownListHandler.removeLinePrefixAndExit, where an empty list item should remove the current line prefix and leave the caret on a plain empty line.

Steps to reproduce

  1. Embed NativeTextViewWrapper with the default list helpers enabled.
  2. Type - item.
  3. Press Enter to create the next list item. The buffer becomes something like:
- item
- 
  1. With the caret on the empty - item, press Enter again.

Expected behavior

The empty list item exits list mode:

- item

The caret should remain on the plain empty line, with no - / bullet marker restored.

Actual behavior

The list prefix is removed briefly, then - is inserted again and the editor returns to an empty unordered list item. Visually this shows as the bullet coming back.

Notes / suspected cause

The current source looks like it intentionally handles this case in MarkdownListHandler.handleInsertion:

contentText.isEmpty for a list line calls removeLinePrefixAndExit(...).

  • removeLinePrefixAndExit(...) removes the prefix and sets the caret at the line start.

The observed behavior looks similar to an NSTextView / Text Services Manager double-insertion issue: the command path handles the Enter and removes the prefix, then a later text insertion path restores the newline/list continuation text.

In our downstream app we previously had to guard this class of issue by blocking the next TSM insert after programmatically removing the empty list prefix. I do not see an equivalent guard in the current engine; performEdit sets isProgrammaticEdit, but that only bypasses delegate handling during the programmatic edit itself.

Environment

  • macOS app using NativeTextViewWrapper
  • TextKit 2-backed editor
  • lists.helpersEnabled == true
  • Reproduced from a local checkout of nodes-app/swift-markdown-engine used as a local Swift package

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions