fix(editor): --- makes a divider; Divider answers to pagebreak, hr, rule #1016

Closed
kayg wants to merge 0 commits from fix/divider-input-rule into dev
Owner

What

kayg, real app (prod cd7f84432): --- on its own line did nothing, and /pagebreak found no Divider.

  1. Input rule (packages/editor/src/syntax/breaks.ts, typeRule): typing the third - of a lone --- line draws the break and moves the caret to the line below (the blank one already there, or a new one). The file still says ---. Undo (⌘Z) brings back the plain --- with the caret after it (two undo steps, split with stopCapturing). Under a line of text a blank line goes in first, so it never becomes a setext heading.
    • Left alone: the first line and an unclosed --- at the top (frontmatter, #982 / ADR 0025), the properties block, code blocks, tables, raw HTML, --- text, ----.
  2. Aliases on the Insert sheet's Divider: pagebreak, page-break, page break, break, separator, hr, line, rule (the sheet's existing keys matching, no new matcher). The sheet has no typo-tolerant matcher or / menu in this tree; it is a substring match on keys.
  3. Insert > Divider under a line of text now puts a blank line first (same setext trap).
  4. Visual: Narrow/Wide already split the card at a break; the gap shows the backdrop and the lower card has no inner shadow (shots in the comment). No CSS change.

Gates (run on dev-01 Chromium, dev-02 WebKit; 1440 + 390)

  • divider-rule.spec.ts (new, 6 tests x 4 projects): pass. width, editor, enter, frontmatter-unreachable: WebKit pass (86 passed, 14 skipped); Chromium pass before the last refactor.
  • breaks.test.ts 11 pass; editor tsc, bun run check (0 errors), bun run lint: pass.
  • First paint vs prod/dev: JS 230,686 B brotli (dev 230,777), CSS 18,386 B (dev 18,386). Not raised.
  • Typing perf ABAB x5: see comment.

Decision: the caret moves below the divider on the third dash (no Enter needed); Enter on a --- line is plain Enter, as before.

## What kayg, real app (prod `cd7f84432`): `---` on its own line did nothing, and `/pagebreak` found no Divider. 1. **Input rule** (`packages/editor/src/syntax/breaks.ts`, `typeRule`): typing the third `-` of a lone `---` line draws the break and moves the caret to the line below (the blank one already there, or a new one). The file still says `---`. Undo (⌘Z) brings back the plain `---` with the caret after it (two undo steps, split with `stopCapturing`). Under a line of text a blank line goes in first, so it never becomes a setext heading. - Left alone: the first line and an unclosed `---` at the top (frontmatter, #982 / ADR 0025), the properties block, code blocks, tables, raw HTML, `--- text`, `----`. 2. **Aliases** on the Insert sheet's Divider: pagebreak, page-break, page break, break, separator, hr, line, rule (the sheet's existing `keys` matching, no new matcher). The sheet has no typo-tolerant matcher or `/` menu in this tree; it is a substring match on `keys`. 3. `Insert > Divider` under a line of text now puts a blank line first (same setext trap). 4. **Visual:** Narrow/Wide already split the card at a break; the gap shows the backdrop and the lower card has no inner shadow (shots in the comment). No CSS change. ## Gates (run on dev-01 Chromium, dev-02 WebKit; 1440 + 390) - `divider-rule.spec.ts` (new, 6 tests x 4 projects): pass. `width`, `editor`, `enter`, `frontmatter-unreachable`: WebKit pass (86 passed, 14 skipped); Chromium pass before the last refactor. - `breaks.test.ts` 11 pass; editor `tsc`, `bun run check` (0 errors), `bun run lint`: pass. - First paint vs prod/dev: JS 230,686 B brotli (dev 230,777), CSS 18,386 B (dev 18,386). Not raised. - Typing perf ABAB x5: see comment. Decision: the caret moves below the divider on the third dash (no Enter needed); Enter on a `---` line is plain Enter, as before.
The third dash of a lone --- line draws the break at once and moves the caret below it
(Undo brings back the plain ---). The first line, an unclosed --- at the top, properties,
code blocks, tables, '--- text' and '----' are left alone. The Insert sheet's Divider
gets the aliases pagebreak, page-break, page break, break, separator, hr, line, rule.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
refactor(editor): smaller --- input rule (first-paint bytes)
Some checks failed
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled
2997e84bb4
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Owner

2x screenshots (Chromium 1440 / 390; Narrow card and Full). before-* = dev 93d9a321a, after-* = this PR. Typed --- at the end of a note, then text. Before: dashes stay visible with the caret on them, nothing below. After: the break is drawn, the caret is on a new line below it, the gap shows the backdrop, and the lower card has no inner shadow.

after-chromium-1440-full-then-text.png
after-chromium-1440-full-then-text.png

after-chromium-1440-full-typed.png
after-chromium-1440-full-typed.png

after-chromium-1440-insert-pagebreak.png
after-chromium-1440-insert-pagebreak.png

after-chromium-1440-narrow-then-text.png
after-chromium-1440-narrow-then-text.png

after-chromium-1440-narrow-typed.png
after-chromium-1440-narrow-typed.png

after-chromium-390-full-then-text.png
after-chromium-390-full-then-text.png

after-chromium-390-full-typed.png
after-chromium-390-full-typed.png

after-chromium-390-insert-pagebreak.png
after-chromium-390-insert-pagebreak.png

after-chromium-390-narrow-then-text.png
after-chromium-390-narrow-then-text.png

after-chromium-390-narrow-typed.png
after-chromium-390-narrow-typed.png

before-chromium-1440-full-then-text.png
before-chromium-1440-full-then-text.png

before-chromium-1440-full-typed.png
before-chromium-1440-full-typed.png

before-chromium-1440-insert-pagebreak.png
before-chromium-1440-insert-pagebreak.png

before-chromium-1440-narrow-then-text.png
before-chromium-1440-narrow-then-text.png

before-chromium-1440-narrow-typed.png
before-chromium-1440-narrow-typed.png

before-chromium-390-full-then-text.png
before-chromium-390-full-then-text.png

before-chromium-390-full-typed.png
before-chromium-390-full-typed.png

before-chromium-390-insert-pagebreak.png
before-chromium-390-insert-pagebreak.png

before-chromium-390-narrow-then-text.png
before-chromium-390-narrow-then-text.png

before-chromium-390-narrow-typed.png
before-chromium-390-narrow-typed.png

2x screenshots (Chromium 1440 / 390; Narrow card and Full). `before-*` = dev 93d9a321a, `after-*` = this PR. Typed `---` at the end of a note, then text. Before: dashes stay visible with the caret on them, nothing below. After: the break is drawn, the caret is on a new line below it, the gap shows the backdrop, and the lower card has no inner shadow. `after-chromium-1440-full-then-text.png` ![after-chromium-1440-full-then-text.png](https://git.kayg.org/attachments/20e926a7-173b-4243-9e50-6229d0becab9) `after-chromium-1440-full-typed.png` ![after-chromium-1440-full-typed.png](https://git.kayg.org/attachments/a22cf117-3edd-4f1c-a1f1-9b17729e37ad) `after-chromium-1440-insert-pagebreak.png` ![after-chromium-1440-insert-pagebreak.png](https://git.kayg.org/attachments/fb8770a3-0d41-4a74-ac23-a1a2871ddaec) `after-chromium-1440-narrow-then-text.png` ![after-chromium-1440-narrow-then-text.png](https://git.kayg.org/attachments/ab6dad18-ee81-463b-b0c2-33fa7279e536) `after-chromium-1440-narrow-typed.png` ![after-chromium-1440-narrow-typed.png](https://git.kayg.org/attachments/46bc95c2-0e30-492d-b54d-4a488771b09c) `after-chromium-390-full-then-text.png` ![after-chromium-390-full-then-text.png](https://git.kayg.org/attachments/e689037c-2ac7-42d2-aaae-a7dc87ea5017) `after-chromium-390-full-typed.png` ![after-chromium-390-full-typed.png](https://git.kayg.org/attachments/92c666a7-8f63-4185-a5e3-f92219df4e62) `after-chromium-390-insert-pagebreak.png` ![after-chromium-390-insert-pagebreak.png](https://git.kayg.org/attachments/e915f27f-0b9f-4919-83cc-a646a8e64f6f) `after-chromium-390-narrow-then-text.png` ![after-chromium-390-narrow-then-text.png](https://git.kayg.org/attachments/823c026c-2e28-4dd8-8f92-385781d6ac4e) `after-chromium-390-narrow-typed.png` ![after-chromium-390-narrow-typed.png](https://git.kayg.org/attachments/97f19b18-edf4-4f5f-a614-86baa0718923) `before-chromium-1440-full-then-text.png` ![before-chromium-1440-full-then-text.png](https://git.kayg.org/attachments/e461d671-0cbd-475b-92cb-6a86b52a12aa) `before-chromium-1440-full-typed.png` ![before-chromium-1440-full-typed.png](https://git.kayg.org/attachments/e848eb1a-d78e-457c-a311-36937f0306e7) `before-chromium-1440-insert-pagebreak.png` ![before-chromium-1440-insert-pagebreak.png](https://git.kayg.org/attachments/39aa58cf-e4e7-423b-aaeb-38baef65310f) `before-chromium-1440-narrow-then-text.png` ![before-chromium-1440-narrow-then-text.png](https://git.kayg.org/attachments/c1223f5c-8177-4e29-b716-48854bf9b4c3) `before-chromium-1440-narrow-typed.png` ![before-chromium-1440-narrow-typed.png](https://git.kayg.org/attachments/f172a035-fe55-499e-b9bf-f2912fd6f836) `before-chromium-390-full-then-text.png` ![before-chromium-390-full-then-text.png](https://git.kayg.org/attachments/3f2d03e1-bae3-4966-912e-7a9c91032537) `before-chromium-390-full-typed.png` ![before-chromium-390-full-typed.png](https://git.kayg.org/attachments/ef75880d-d660-4e6c-96eb-c58d5e819a7e) `before-chromium-390-insert-pagebreak.png` ![before-chromium-390-insert-pagebreak.png](https://git.kayg.org/attachments/2f77e896-4cef-4abd-acbd-e56dddf3d1e4) `before-chromium-390-narrow-then-text.png` ![before-chromium-390-narrow-then-text.png](https://git.kayg.org/attachments/888d56ee-4a28-4ec0-8825-646b753d6584) `before-chromium-390-narrow-typed.png` ![before-chromium-390-narrow-typed.png](https://git.kayg.org/attachments/7f3a175b-892e-408f-95ca-1c5717a0ea2f)
Author
Owner

Typing-path perf ABAB x5 NOT run yet (open gate; do not merge before it). Both perf locks were held by the Files s1 lane, and it extended its holds by 2 h while I was queued, so my run could not start. I released my queue spots so I don't block that lane.

Ready to go on perf-02 (~/perf/pf): dev build web-drdev, this PR's build web-drrule, dr-go.sh (typing.perf.ts, 5 rounds, devA / PR / devB control). Run: take ~/bin/perf-lock on perf-01 then perf-02, then ~/perf/pf/dr-go.sh.

Why the risk is small: the rule is one EditorView.inputHandler that returns false at once unless the typed text is exactly - (and is not in the frontmatter or a first-line ---); only then does it build one hypothetical state and look at one line.

**Typing-path perf ABAB x5 NOT run yet (open gate; do not merge before it).** Both perf locks were held by the Files s1 lane, and it extended its holds by 2 h while I was queued, so my run could not start. I released my queue spots so I don't block that lane. Ready to go on perf-02 (`~/perf/pf`): dev build `web-drdev`, this PR's build `web-drrule`, `dr-go.sh` (typing.perf.ts, 5 rounds, devA / PR / devB control). Run: take `~/bin/perf-lock` on perf-01 then perf-02, then `~/perf/pf/dr-go.sh`. Why the risk is small: the rule is one `EditorView.inputHandler` that returns false at once unless the typed text is exactly `-` (and is not in the frontmatter or a first-line `---`); only then does it build one hypothetical state and look at one line.
Author
Owner

Final gates on head 2997e84bb

Chromium 1440 + 390, width, editor, enter, frontmatter-unreachable, divider-rule: 85 passed, 15 skipped (the phone/wide skips the specs already have), 0 failed.

Typing-path perf, ABAB x5 (perf-02, both perf locks held, Chromium with 4x CPU slowdown, 10k Home, perf/typing.perf.ts, same server binary for every arm, rounds rotated, devA = dev 93d9a321a, devB = the same dev build again as the control, rule = this PR). Median of the 5 per-run medians, with [min-max]. Keystroke to paint, ms:

metric devA devB (control) rule (PR)
long note, p50 22.00 [21.40-22.40] 21.60 [21.00-22.20] 21.70 [21.00-22.30]
long note, p95 52.2 [45.5-60.2] 63.7 [48.3-67.3] 58.8 [53.8-62.6]
long note, CPU per key 26.63 [26.60-27.45] 26.50 [25.72-26.83] 26.30 [25.58-26.74]
nested list, p50 41.70 [41.40-42.30] 42.00 [41.60-45.10] 42.00 [41.50-42.80]
nested list, p95 51.2 [50.5-55.4] 52.2 [49.0-58.0] 51.2 [49.4-52.2]
nested list, CPU per key 49.01 [48.42-49.89] 48.99 [48.58-52.85] 48.80 [48.46-50.49]

dev-vs-dev control differs by up to 11 ms on p95 (noise); the PR sits inside the control's spread on every row, and its p50 and CPU medians are equal to or below dev's. No regression.

Notes: the typed text in this harness has no -, so it measures the path every ordinary keystroke takes (the rule returns at once unless the key is exactly -). A - keystroke does extra work only on lines near a possible ---; not in the harness. The harness' code-block tests are not in this checkout of the runner (2 tests ran). A first attempt failed on every run because a Nix font directory had been garbage-collected; I fixed the runner's fontconfig and re-ran everything (the failed attempt's data is discarded). Locks: I waited my turn, took perf-01 then perf-02, and released both.

## Final gates on head 2997e84bb **Chromium 1440 + 390, `width`, `editor`, `enter`, `frontmatter-unreachable`, `divider-rule`:** 85 passed, 15 skipped (the phone/wide skips the specs already have), 0 failed. **Typing-path perf, ABAB x5** (perf-02, both perf locks held, Chromium with 4x CPU slowdown, 10k Home, `perf/typing.perf.ts`, same server binary for every arm, rounds rotated, `devA` = dev 93d9a321a, `devB` = the same dev build again as the control, `rule` = this PR). Median of the 5 per-run medians, with [min-max]. Keystroke to paint, ms: | metric | devA | devB (control) | rule (PR) | |---|---|---|---| | long note, p50 | 22.00 [21.40-22.40] | 21.60 [21.00-22.20] | 21.70 [21.00-22.30] | | long note, p95 | 52.2 [45.5-60.2] | 63.7 [48.3-67.3] | 58.8 [53.8-62.6] | | long note, CPU per key | 26.63 [26.60-27.45] | 26.50 [25.72-26.83] | 26.30 [25.58-26.74] | | nested list, p50 | 41.70 [41.40-42.30] | 42.00 [41.60-45.10] | 42.00 [41.50-42.80] | | nested list, p95 | 51.2 [50.5-55.4] | 52.2 [49.0-58.0] | 51.2 [49.4-52.2] | | nested list, CPU per key | 49.01 [48.42-49.89] | 48.99 [48.58-52.85] | 48.80 [48.46-50.49] | dev-vs-dev control differs by up to 11 ms on p95 (noise); the PR sits inside the control's spread on every row, and its p50 and CPU medians are equal to or below dev's. No regression. Notes: the typed text in this harness has no `-`, so it measures the path every ordinary keystroke takes (the rule returns at once unless the key is exactly `-`). A `-` keystroke does extra work only on lines near a possible `---`; not in the harness. The harness' code-block tests are not in this checkout of the runner (2 tests ran). A first attempt failed on every run because a Nix font directory had been garbage-collected; I fixed the runner's fontconfig and re-ran everything (the failed attempt's data is discarded). Locks: I waited my turn, took perf-01 then perf-02, and released both.
Author
Owner

Merged into dev (U1). Checked the 2× strips: narrow card splits into two cards with the backdrop in the gap; full width draws the rule. Specs green in Chromium + WebKit at both sizes, typing perf flat vs dev control, first paint −91 B JS.

Merged into dev (U1). Checked the 2× strips: narrow card splits into two cards with the backdrop in the gap; full width draws the rule. Specs green in Chromium + WebKit at both sizes, typing perf flat vs dev control, first paint −91 B JS.
kayg closed this pull request 2026-11-08 08:50:36 +00:00
Some checks failed
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled

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!1016
No description provided.