#187. OrgEditor.init no longer restyles the whole file. The settings styling reads (indented, hideStars, shrunk columns, inline images, LaTeX previews) are set from Presentation.startupDisplay before load, so the first chunk and the background passes use them. load records the caret's line as the revealed one, so the line styled with the caret at the end is restyled when the caret moves to the start.
#189. restyle applies line indents and roles together in ascending order of start. Roles are sorted by start with their original index as tie-break, which keeps outer before inner; a src block's highlighter runs keep their own order (later wins) and sort as one unit.
Gates, release build, median of four runs, same machine before and after (shared with other builds; these runs were taken at load 2 to 5):
| File | Measure | Before | After | Gate |
|---|---|---|---|---|
| Single 1 MB section | open | 558 ms | 131 ms | 100 ms |
| typing / blank line p95 | 9.6 / 11.0 ms | 9.8 / 11.5 ms | 16 ms | |
| memory | 39.2x | 33.1x | 45x | |
| 5,000-row table (312 kB) | open | 134 ms | 49 ms | 100 ms |
| typing / blank line p95 | 4.4 / 9.9 ms | 4.5 / 10.1 ms | 16 ms | |
| memory | 52.7x | 42.2x | 45x | |
| 3,000 entries with drawers (821 kB) | open | 235 ms | 113 ms | 100 ms |
| typing / blank line p95 | 8.9 / 8.9 ms | 9.3 / 9.3 ms | 16 ms | |
| memory | 25.0x | 23.2x | 45x | |
csg.org (1,545 kB) |
open | 212 ms | 120 ms | 155 ms |
| typing / blank line p95 | 10.6 / 11.2 ms | 11.2 / 11.7 ms | 16 ms | |
| memory | 11.6x | 11.1x | 10x |
Still failing: open for the 1 MB section and the drawers file, and memory for csg.org. The parse alone (DocumentState(bytes:)) is 82 ms of the 1 MB section's 131 ms and 62 ms of the drawers file's 113 ms; OrgEditor.init is now 23 ms and 39 ms.
Styling a mixed document after open (finishStyling), best of three:
| 1 MB | 2 MB | 4 MB | 10 MB | |
|---|---|---|---|---|
| Before | 1.42 s | 5.93 s | 24.1 s | not run |
| After | 0.22 s | 0.45 s | 0.91 s | 2.29 s |
Typing p95 in the middle of a large file is unchanged (12 / 23 / 44 / 110 ms at 1 / 2 / 4 / 10 MB). Restyling one paragraph there costs 3.9 ms at 10 MB, so the rest is in storageEdited outside styling.
Styling is unchanged: an attribute digest of the storage (run boundaries, fonts, colors, paragraph styles) is identical before and after for the three gate files, csg.org, a mixed document, noindent and an entity-heavy file, each with markup shown, markup hidden and a proportional body font.
Tests: swift test green; both Xcode builds succeed. New: openingLeavesTextPastTheFirstChunkUnstyled (fails on main), startupDisplayAppliesToEveryChunk, laterHighlighterRunsWin.