Repository navigation
Text & Markdown: shape code blocks one Layout per line (El::by_line) - #1133
Conversation
Streaming a fenced code block previously reshaped the whole block's text on every appended token (`O(L)` lines per commit). - Add `El::by_line` (`TextSpec::by_line`), laying out a multi-line static text element as one `ParagraphLayout` (`Rc<Layout<Ink>>` per newline-ended line) while keeping a single selectable `Node` in its resolved base direction (`Direction::Ltr` on `Block::Code`). - Carry `ParagraphLayout` across commits and relayouts on `by_line` nodes, slice disjoint spans by binary search, strip `\r` before `\n`, and re-break multi-line wrapped lines at their accumulated fractional `line_y` phase (`rebreak_at_y`) so wrapped lines at fractional display scales (such as `1.875x`) quantize identically to a single `Layout`. - Support `TextFlow::Paragraphs` across static text selection (`selectable`, `rects`, `text_marks`, `links`), `stream_height_lag`, `RevealPhase` word-fade byte mapping, and `highlight_decorations_flow` (including multi-line Find highlights crossing `\n` and blank lines), and mark `Markdown` `Block::Code` with `.by_line()`.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
TEXT-2 review of
Checks before merge:
Outside code blocks. The by-paragraph path now passes For my own work. |
|
Windows whole suite ( |
|
TEXT-2, on the independent read's two findings (
|
…e by_line runs, and unify highlight decos
Address review findings on `El::by_line` (`notes/review-1133.md` and TEXT-2 review):
- Pass `spec.by_line && spec.pretty() && !input` in `lay_out_paragraphs` (`crates/rune/src/text/paragraphs.rs`) so multi-paragraph drafts in editors keep greedy line breaking (`pretty.rs`) instead of re-breaking earlier lines as the user types.
- Give an empty trailing slice after `\n` zero height on `spec.by_line` so `text("a\n").by_line()` and closed fences with a trailing blank line match `TextLayout::Single`'s height.
- Restore decoration paint order (`pill_chips` -> `decorations_with_rings` -> `highlight_decorations_flow` -> `strike_decorations` -> `link_fx`) in `crates/rune/src/runtime/paint/content.rs` so Find match fills paint beneath strikethroughs and link hover effects on both ringed and ringless paths.
- Count `LAYOUT_BASE` per shaped line in `TextSystem::paragraphs` cache entries, and keep `AsciiLine` waiting runs for off-screen lines of large plain or colour-only `by_line` blocks (`crates/rune/src/text/paragraphs/{keying,lazy}.rs`, `crates/rune/src/runtime/text_fill.rs`).
- Extend `a11y::text::lines` (`crates/rune/src/a11y/text.rs`) by 2 bytes over `\r\n` so screen-reader text runs cover CRLF code blocks end to end.
- Unify `highlight_decorations` and `highlight_decorations_flow` onto one `push_highlight_boxes` body in `crates/rune/src/text/decorations.rs`, and document `El::by_line`'s single-layout fallbacks and dropped text flights.
|
Addressed all five review findings and your three checks in fast-forward head
|
…p pre-paint, and key pretty wrap
This reverts commit 2bd88e5 and keeps its test. Upstream's reworked paragraph painting (Piece and TextFlow::Paragraphs, anomalyco#1133, with colour-only spans resolved at glyph emission, anomalyco#1116) cuts highlights to each paragraph itself: tests/highlight_pieces.rs passes on upstream's dev without this commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit 0d291cc. Upstream's highlight_boxes_in now reads a field's boxes through TextLayout::view and TextFlow::range_boxes, which covers a by-paragraph field (anomalyco#1057, with TextFlow::Paragraphs carried through links, rects and selectable in anomalyco#1133), and links::origin takes a TextFlow there too. Quire's find-in-source tests (wr_118_*) check it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…1292) * feat(rune-kit): native code-block soft wrapping and text-wrap icon Add native code-block soft wrapping to `rune-kit::markdown` and the `text-wrap` icon (`icons::TEXT_WRAP`) to `rune-theme-opencode` for `anomalyco/opencode#64545`: - `MarkdownStyle::wrap_code(bool)`, `Markdown::wrap_code(bool)`, and `Markdown::code_wrap(Fn(usize, &str) -> bool)` wrap long lines inside `Renderer::code` via `.by_line().wrap_anywhere().wrap_greedy()` while keeping `#1133` per-line shaping, screen-reader `TextRun` line runs, `#1130` `settled_code_card_digest` memoisation, Find highlights, streaming reveal, `.copy_breaks(2, 2)`, non-mono tab stops, and shell block colours. - Unwrapped blocks (`!wrapped`) remain identical to before. - `Source` computes longest-line tab-expanded stats once at parse time; `CodeFrame::overflows` answers overflow against `text_width - flow.inset` in O(1) on the ASCII monospace fast path (falling back to `rune::text::measure` only near the boundary or for non-ASCII/non-mono). - `CodeFrame::wrapped` reports the block's active wrap state. - `rune-theme-opencode::icons::TEXT_WRAP` adds Desktop's `text-wrap` SVG. * fix(rune-kit): address review #1292 findings (stable body path, lazy exact overflows, lock-free font_epoch, line reuse, scoped memo) * fix(rune-kit): revert paragraphs.rs scope creep, clear ascii/paragraphs on font switch, Acquire/Release font_epoch, bound control chars
Streaming a fenced code block previously laid out the entire block in one
parley::Layout(TextLayout::Single), reshaping all0..Llines on every appended token (O(L)per commit). This PR addsEl::by_line(crates/rune/src/el/paragraphs.rs,crates/rune/src/text/paragraphs.rs) and applies it toMarkdownBlock::Code(crates/rune-kit/src/markdown/render.rs) so each newline-delimited line shapes into its ownRc<Layout<Ink>>inside oneParagraphLayoutwhile unchanged lines are reused across commits (O(1)trailing line shaped per token; long plain/colour-only fixed-pitch ASCII interiors wait as compactAsciiLineruns, and colour-only syntax spans bypass layout keying viaspan::layout_spans).flowchart LR D["Appended code token"] --> K["key_paragraphs + span::layout_spans<br/>(strip CRLF CR; pack interior fixed-pitch ASCII lines into AsciiLine runs;<br/>colour-only spans skip line/run keys)"] K --> M{"Line / run key matches<br/>previous ParagraphLayout?"} M -->|Yes: settled lines 0..L-1| R["Reuse Rc<Layout<Ink>> or waiting run<br/>(0 HarfBuzz shaping)"] M -->|No: open trailing line| S["Shape 1 line (Keep::Owned);<br/>rebreak_at_y(y - floor(y)) if wrapped"] R --> P["Pre-paint fill_visible_by_line (shared visible_text_rows) → Single Node:<br/>pills/span-bg → highlights → strikes/link-fx → marks → selection → glyphs"] S --> PDesign & post-review updates (
e23dcc73overdev1505f921)One
Layoutper line on a singleNode(El::by_line):Block::Coderemains a singleEl/Nodeinsideframe(role("code")), marked.by_line()(TextSpec::by_line). Element paths,ElementInfo, accessibility, Taffy's node count,El::reveal(RevealPhase), andEl::selection_groupmembership stay identical toTextLayout::Single.El::by_linedoc):El::by_linesilently falls back toTextLayout::Singlewhen the text does not wrap (!spec.wrap), is truncated or line-clamped, is live (El::live/El::advance_in), is redacted, is an input, or is a shared-run cell (text_spec.rs:290-294), and a text flight landing on aby_linenode is dropped (paint/text_flights.rs:20) so the text appears in place without flying (set_pretty_wrapstays active on proportionalby_lineblocks and greedy on editors, salted by0x7072_6574_7479_0001inTextSystem::paragraphsso identical field andby_linetexts never collide in cache).visible_text_rows, ќspan::layout_spans(paragraphs.rs,keying.rs,lazy.rs,runtime/text_fill.rs,paint/content.rs):TextSystem::paragraphscountsLAYOUT_BASE(2 KiB) per shaped line, keeps interior printable-ASCII lines (48..N-48pastLAZY_MIN) in fixed-pitch monospace faces (AsciiLine::fixed_pitch) as deferredAsciiLineruns (512lines/run), filterskey_paragraphsandsplit_runhashes through#1116'sspan::layout_spans(s.hash_layout) so syntax recolouring reshapes0lines, and sharesvisible_text_rowsbetweenfill_visible_by_lineandpaint_contentso jumping into the middle of a2,000-line block shapes visible interior lines on frame 1 (0diff px vs settled across1x,1.5x,1.875x).TextRuns without accessibility trade (a11y/text.rs,paragraphs.rs,keying.rs,lazy.rs):a11y::text::linesbuilds exactTextRuns (Lines) for waitingAsciiLineruns directly from their ASCII text, fixed-pitchAsciiLineadvances/height, per-linef64yaccumulation, andicu_segmenterword starts, matching Parley's shapedpush_bidi_line_runsbit-for-bit (0differing ranges and0differing device-pixel boxes). Non-ASCII, raw-\t, empty, RTL, or wrapping lines in aby_lineblock are not deferred bykey_paragraphs— they shape eagerly inlay_out_paragraphs(< 1–2%of lines in real source code) and emit shapedTextRuns beside their waiting ASCII neighbours, whilea11y_linesallowsspec.by_lineblocks pastRUN_MAX_BYTES(64 KiB) up toLINK_BASE - 2(32,766runs) so both< 64 KiBand> 64 KiB2,000-line code blocks publish full line-by-line and character-by-character runs immediately before any scroll.text/decorations.rs,paint/content.rs):highlight_decorationsandhighlight_decorations_flowshare onepush_highlight_boxesbody, andpaint/content.rspaintspill_chips -> decorations_with_rings -> highlight_decorations_flow -> strike_decorations -> link_fxacross visible pieces beneath strikethroughs and link hover effects.What changes in the shared by-paragraph path outside code blocks (multi-line text fields / composer):
1device px fix): wrapped paragraphs below an earlier paragraph now break withrebreak_at_y(y - floor(y))and sit atfloor(y), moving wrapped sub-lines by up to1device pixel at1.5xand1.875xso pressing Enter matches single-layout line placement.0.25 * (ascent + descent)), and a selected blank line's baseline comes from quantized base-font extents (blank_box).\rstripping: multi-paragraph fields paint all decorations, then marks, then selections, then glyphs across visible paragraphs, and strip\rbefore\nfrom shaped paragraph slices while keepingspec.contentbyte offsets intact.Verification (
e23dcc73overdev1505f921: 24 files,+955 −508,0test files/attributes,0unsafe)adais): all439 / 439rune-kittests (0failed,3ignored across all 50 binaries;proof/proof-farm/700de94f-5a0e-4850-bba4-9efdb39c6c28),129 / 129runeliba11y+textunit tests (0failed,1ignored;proof/proof-farm/ee83e1da-9089-4808-972d-1ad89ea7f9b9), and90 / 90passingrunetext/selection/caret/links/deco integration tests across 21 binaries (0new failures;proof/proof-farm/fc43060e-f7c7-4af0-b264-69dbac475ae0).proof/stream/pr1133-final-rows/summary.json,OPENCODE_RUNE_OTEL=0, UIA client):< 64 KiB(34,898 B, including an interior non-ASCII line) &> 64 KiB(95,779 B) UIA line + char walk & arithmetic-vs-shaped equality: before any scroll, UIA walks all2,000lines byTextUnit_Lineand all34,895/95,779characters byTextUnit_Characterwith0holes; after scrolling every waiting line into view so all2,000lines shape,0 / 2,000ranges and0 / 2,000device-pixel boxes differ on either block (mid_viewport_differing_boxes = 0).y = 20,000 pt):0diff px vs settled across1x,1.5x,1.875x.500 -> 900colour-only spans on2,000lines):0layouts reshaped (109initial shaped layouts).by_lineblock wrapping: greedy intext_input,prettyinby_line(1,201diff px between them,0diff px vs standalone in both cache orders).Per-token streaming
Block::Codecost (proof/stream/code-by-line-timing/summary.json, pre-09:10 valid blade window)µs)TextLayout::Single)El::by_line)text_shapep50 / p95 / max393/871/1,46369/135/290-324 µs(5.7xfaster) /-736 µs/-1,173 µslayoutp50491228-263 µs(-53.6%)commitphase p501,4781,171-307 µs2,867(2,782)2,491(2,415)-376 µs(-367 µsCPU)