Repository navigation
Text: keep colour-only spans out of the shaping key and resolve their ink at glyph emission - #1116
Conversation
… ink at glyph emission A span that sets only `color` (search highlights, syntax tokens) does not change glyph shaping, advances, line breaking or painted decorations: Parley already shapes across brush edges. Keeping colour-only spans out of `text_hash`, `ParagraphLayout`'s paragraph keys and Parley's `Brush` runs lets highlighted text reuse plain and earlier-highlighted layouts (and cached truncations) without reshaping. `TextSystem::set_glyph_inks` records coloured span byte ranges alongside the smoothing and gamma buckets. Glyph emission and `GlyphCache` map each glyph to its cluster's first logical byte (`cl.glyphs()` on `is_atom_start()`) and resolve its `ink` before the atlas mask / Windfoil lookup, so per-ink dilation, DirectWrite gamma and synthetic bold keep their exact behaviour, and `text_quads` hashes span ranges with their colours.
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.
|
Windows whole suite ( |
…th a cursor Addresses the #1116 review findings: - Share `span::layout_spans` (`start < end && affects_layout()`) across `text_hash`, `key_paragraphs`, Parley `Brush` ordinals, `decorations_into` and `synthetic_bold::inks`, so empty spans created by truncation never shift brush ordinals on a shared layout. - Resolve coloured spans once in `set_glyph_inks` into sorted, non-overlapping `(start, end, ink)` intervals and walk them with a forward cursor (falling back to binary search on jumps) instead of scanning every coloured span per glyph; collect `layout_spans` once per `decorations_into` call. - Look up byte 0 in `glyphs_in_scaled`, since `ink_spans` holds the cell's own spans rather than the shared run's.
|
Pushed
|
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]>
Colour-only
Spans (colorwith noweight,mono,size,italic,bgorunderline) do not change glyph shaping, advances, line breaking or painted decorations: Parley already shapes acrossBrushboundaries (parley::shape::shape_textsplits only on font, size, locale, variations, features and spacing). Keeping non-empty layout-affecting spans alone intext_hash,ParagraphLayout's paragraph keys and Parley'sBrushruns lets highlighted text reuse plain and previously highlighted layouts (and cachedElisiontruncations) without reshaping.text/span.rs,text/hash.rs,text/paragraphs.rs,text.rs,text/decorations.rs,text/synthetic_bold.rs):span::layout_spans(s.start < s.end && s.affects_layout()) is shared acrosstext_hash, per-paragraph hashes, ParleyBrush(Ink(ordinal))pushes,decorations_into(collected once per call) andsynthetic_bold::inks, so a span gets a brush ordinal if and only if it entered the shaping key (including after head or middle truncation cuts an earlier layout span to an empty range).text.rs,text/glyph_emit.rs,text/glyph_cache.rs,text/windfoil.rs):TextSystem::set_glyph_inksresolves coloured spans once (set_ink_spans) into sorted, non-overlapping(start, end, ink)intervals where later spans win, alongside the smoothing/gamma buckets.line_glyph_byteswalks each run's clusters in visual order and gives every glyph in a cluster that cluster's first logical byte (cl.text_range().start, covering ligatures, combining sequences and RTL runs).ink_atsteps a forward cursor in O(1) (falling back topartition_pointbinary search on jumps) in bothglyphs_in_bandandGlyphCache::replay, resolvinginkbeforeapple.radius/windows.bucket/GlyphKeylookup. Shared-run cells (glyphs_in_scaled/advance_in) look up cell byte0, matching their cell-relativeink_spans.runtime/paint/content.rs): passes elision-remappedspanstoset_glyph_inksand hashes(sp.start, sp.end, sp.color)intext_quadsso a sharedLayoutIdrepaints when its highlight range or colour changes.flatten_spans):rich(),El::spans()(with_pill_colors) andtext_inputdecorations flatten overlapping spans. When a colour range overlaps a layout-affecting span (weight,mono,size,italic,bgorunderline), flattening splits that layout span at the colour's edges so those split points still enter the shaping key (for example a match inside inline code or inside a bold label still reshapes when its highlight moves). Unstyled text with search highlights andSyntaxTheme::spanscode blocks (which emit colour-only spans, plus weight on Markdown headings) keep a stable key.9f465b74vsb12a7972): 0 differing pixels between Rune before and Rune after across 12(query, scale, scheme)captures at 1x and 1.5x (light and dark, covering"fi","ff"and"Te"), and across the driven review scenes (trunc-ab,trunc-ba,shared-colors,copy-repaintsteps 0–2,edges-allligature/combining/RTL/bidi/synthetic-bold rows at 1x and 1.5x, and app palette, diff and live light→dark theme-switch captures; note this 0-pixel figure compares Rune before against Rune after, not against Chromium).Before / after (
opencode-desktop, headless 1x,release-quick --features frame-profile, exclusive quiet windows)9f465b74→b12a7972)9f465b74→be26ed6c→b12a7972)"Target", first open)be26ed6c)"Target", first open)Targ..Target)"Toggle", 6 rows kept)T..Toggle)~12kcolour spans)text_cpu: 3.18 → 2.21 → 2.16 ms~12kcolour spans)bytes = trueper-glyph walk~12kcolour spans)GlyphCache::replay~12kcolour spans)text_quadscopy path