One Return, one new line: no blank line in lists (#225) #239

Closed
kayg wants to merge 0 commits from issue/225-ios-return into dev
Owner

Fixes #225.

Cause: an input bug, not a layout one. kayg's note on calternal.cloud has real blank lines in the file: four empty lines after the log line, and - / blank / lines at the end. Once a list has a blank line anywhere, CodeMirror's markdown Return treats it as a "loose" list and puts a blank line before every new bullet. Return on an empty item then pushes it down a line instead of ending the list. So one Return gave two line breaks, and kept doing so from then on.

It is not iOS sending Return twice. In WebKit with an iPhone user agent, CodeMirror's iOS path runs (keydown, the browser's own insertLineBreak, then one replayed Return): the command runs once. Empty lines are drawn at normal height (the new e2e test checks this).

Change

  • packages/editor/src/lists/enter.ts: our Return for lists. It wraps CodeMirror's command, drops the blank line it would add, and always ends the list on an empty item (or steps out one level when nested). Numbering, tasks, quotes and nesting stay CodeMirror's.
  • editor.ts: bound ahead of the markdown keymap.

Tests

  • packages/editor/test/enter.test.ts: loose list (kayg's note), tight list, empty item ends the list (also after a blank line and as a second item), nested, numbers, tasks, log line split, heading and plain text left alone. 4 of 7 fail without the fix.
  • apps/web/e2e/enter.spec.ts: real Return in Chromium and WebKit (iPhone user agent, so the iOS path), at 390 and 1440: list item, empty item, log line, heading, plain text, no gap under the new bullet, and an empty line as tall as a text line. Two tests fail without the fix in both browsers.

The blank lines already in kayg's note stay. This change only stops new ones.

🤖 Generated with Claude Code

https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T

Fixes #225. **Cause: an input bug, not a layout one.** kayg's note on calternal.cloud has real blank lines in the file: four empty lines after the log line, and `- ` / blank / ` ` lines at the end. Once a list has a blank line anywhere, CodeMirror's markdown Return treats it as a "loose" list and puts a blank line before every new bullet. Return on an empty item then pushes it down a line instead of ending the list. So one Return gave two line breaks, and kept doing so from then on. It is not iOS sending Return twice. In WebKit with an iPhone user agent, CodeMirror's iOS path runs (keydown, the browser's own `insertLineBreak`, then one replayed Return): the command runs once. Empty lines are drawn at normal height (the new e2e test checks this). **Change** - `packages/editor/src/lists/enter.ts`: our Return for lists. It wraps CodeMirror's command, drops the blank line it would add, and always ends the list on an empty item (or steps out one level when nested). Numbering, tasks, quotes and nesting stay CodeMirror's. - `editor.ts`: bound ahead of the markdown keymap. **Tests** - `packages/editor/test/enter.test.ts`: loose list (kayg's note), tight list, empty item ends the list (also after a blank line and as a second item), nested, numbers, tasks, log line split, heading and plain text left alone. 4 of 7 fail without the fix. - `apps/web/e2e/enter.spec.ts`: real Return in Chromium and WebKit (iPhone user agent, so the iOS path), at 390 and 1440: list item, empty item, log line, heading, plain text, no gap under the new bullet, and an empty line as tall as a text line. Two tests fail without the fix in both browsers. The blank lines already in kayg's note stay. This change only stops new ones. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
CodeMirror's markdown Return kept a list loose once it had a blank line:
each Return added a blank line before the new bullet, and Return on an
empty item pushed it down instead of ending the list. Our own Return
command drops that blank line and always ends the list on an empty item.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Enter test: hand the finished parse to the state (#225)
Some checks failed
CI / web (pull_request) Failing after 24s
CI / rust (pull_request) Successful in 1m52s
00d92a7518
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Author
Owner

Review: the cause is real. kayg's note has blank lines inside a list, so CodeMirror's loose-list Return adds a blank line before each new item and pushes an empty item down instead of ending the list.

The fix wraps Return to drop the added blank line and end the list on an empty item. The new enter tests fail without the fix.

After merging dev: svelte-check reports 0 errors. The editor vitest run has 93 passing and 3 failing, all three timing guards (hidden-cost, tree-cost, local-copy compaction) on a box at load ~100; none of them touches Return.

Merging.

Review: the cause is real. kayg's note has blank lines inside a list, so CodeMirror's loose-list Return adds a blank line before each new item and pushes an empty item down instead of ending the list. The fix wraps Return to drop the added blank line and end the list on an empty item. The new enter tests fail without the fix. After merging dev: svelte-check reports 0 errors. The editor vitest run has 93 passing and 3 failing, all three timing guards (hidden-cost, tree-cost, local-copy compaction) on a box at load ~100; none of them touches Return. Merging.
kayg closed this pull request 2026-10-14 11:15:47 +00:00
Some checks failed
CI / web (pull_request) Failing after 24s
CI / rust (pull_request) Successful in 1m52s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!239
No description provided.