BlueGit

ict rusty-teams

Files

rusty-teams / vendor / gpui-base / PATCH.md

PATCH.md

PATCH.md 9.0 KiB Download Raw

gpui-base 0.7.1 patches

Upstream: crates.io gpui-base 0.7.1 (git 87d10ae5, crates/base). Wired in via [patch.crates-io] in the root Cargo.toml.

Changed files

FileChangeWhy
Cargo.tomlempty [workspace] table at the endcargo test --manifest-path vendor/gpui-base/Cargo.toml works inside the app workspace (and nested worktrees)
src/input/editor/decorations.rsTextDecoration.font_family, with_font_family(), FontOverride (family, weight, style), font_override_spans() reading font_family + style.font_weight / style.font_style, adjust_range_for_edit made pub(crate), doc on layeringfont per byte range; first collection / item wins per property
src/input/editor/display_map/text_wrapper.rsfont_overrides on TextWrapper, split_run_by_font_overrides(), set_font_overrides() / adjust_font_overrides(), measured_wrap_boundaries measures by range, shared changed_ranges() / rewrap_rows_of()soft wrap measures mono / bold / italic ranges in their own font
src/input/editor/display_map/wrap_map.rs, display_map.rs, mod.rspass-through for set_font_overrides, export split_run_by_font_overridesplumbing
src/input/base/element.rsprepaint pushes font-override spans into the display map; render runs split by font overrideglyphs, caret, selection and hit testing use the same shaped runs
src/input/base/state.rsset_hanging_indents(markers) on multi-line states (textarea and editor)list lines: continuation rows start under the text after •, ◦, 12.
src/input/editor/display_map/text_wrapper.rshanging_indents on TextWrapper, hanging_indent_at(), measured_wrap_boundaries(.., hanging_indent, ..), shift_span() shared with inline metrics; a line with a marker always wraps as WrappingIndent::Samewrap continuation rows at wrap_width - marker width; the existing LineItem.indent / LineLayout.wrap_indent path then shifts rendering, caret, selection, hit testing and up/down moves
src/input/editor/display_map/wrap_map.rs, display_map.rspass-through for set_hanging_indents, adjust on editplumbing
src/input/base/kind.rsTextareaExtras (text + range decorations) as TextareaMode::Extras; edit tracking and reset hooks; sealed DecoratedMode trait for both multi-line modesdecorations on TextareaState (composer stays a textarea)
src/input/editor/decorations.rsTextDecorationCollection<M = EditorMode>, RangeDecorationCollection<M = EditorMode>, create_*_collection on impl<M: DecoratedMode>; DecorationCollections / TrackedDecoration pub + #[doc(hidden)]same API on textarea and editor; default type param keeps editor code unchanged
src/input/editor/mod.rs, src/input/mod.rsdoc no longer says decorations are editor-only; export DecoratedMode, TextareaExtrasdocs, API
src/input/editor/display_map/text_wrapper.rslines with inline tokens wrap through measured_wrap_boundaries too (atomic token ranges, token width + shaped text segments) instead of gpui's LineWrappermention lines honour font overrides and hanging indent
src/input/base/state.rs, src/input/editor/display_map/*, src/input/base/element.rsset_line_indents(Vec<(line start, Pixels)>): every row of a line starts at its indent and wraps that much earlier; LineLayout.first_indent feeds caret, selection, hit testing and up/down; combines with a hanging indent; without one, continuation rows start at the line indent, not under leading spacesnested list levels, quote gap and code padding without padding characters in the text
src/input/editor/decorations.rsRangeDecorationStyle::{Pill, Block, Bar}, RangeDecoration::with_border() / with_radius(); Block and Bar keep empty ranges (TrackedDecoration::keeps_empty) and the index finds themrounded inline code pills, full-width code block fill, quote bar; a block over one empty line
src/input/base/element.rslayout_range_decoration_quads() paints pills, blocks and bars as quads below the fillsrounded corners and borders, which paths cannot draw
src/input/base/state.rsapply_edits(&[(Range, String)]) on all statesseveral edits in one undo step without touching inline tokens between them
src/input/base/inline_tokens.rs, src/input/base/token_presentation.rsInlineToken::block() / is_block() (part of Hash and Eq), InlineTokenContext::is_block(), token layout cache keeps a Size per token (sizes)a token that sits alone on its own row at its rendered height, e.g. an image preview in the composer
src/input/editor/display_map/text_wrapper.rsInlineMetric { range, width, height } replaces (Range, Pixels); measured_wrap_boundaries(.., forced, ..) ends a row at each block token edge; LineItem.blocks, LineSummary.block_rows / block_height, BlockExtent dimension; TextWrapper::row_top / row_height / row_at_y / content_height; LineLayout::row_top / row_height / row_at_y; InputLine.heightrows are no longer uniform: a row that is exactly one block token has the token's height, lookups stay O(log n)
src/input/editor/display_map/display_map.rs, wrap_map.rs, mod.rsDisplayMap::row_top / row_height / row_at_y / content_height / content_rows, InlineMetric plumbing and exportplumbing
src/input/base/element.rsblock tokens measured with MinContent height (always, also off-screen); caret top and height, selection corners, Block / Bar decoration height, visible range, scroll size and token placement use the row helperscaret, selection and paint follow the taller row
src/input/base/state.rs, movement.rs, mode.rsscroll_to, hit testing, IME bounds, line_and_position_for_offset and Up / Down use the row helpers; update_auto_grow(display_map, line_height) counts content_rowsclick, scroll and arrow keys land on the right row; auto grow fits the image
src/input/base/mode.rs, element.rsupdate_auto_grow lets the auto-grow height exceed max_rows by the rows block tokens add, up to BLOCK_GROWTH_FACTOR (2) times max_rows; the textarea min height uses mode.rows()an image does not use up the text row budget
src/input/base/element.rslayout_cursors also follows the caret on a frame where an auto-grow viewport changed height (viewport_changed), not only when the selection changedtext typed after a block token, or loaded content, stays visible while the viewport is still growing
src/input/editor/decorations.rsTextDecoration.font_scale / baseline_shift, with_font_scale() / with_baseline_shift(), FontOverride.scale / raise, product_spans() (scales multiply, first raise wins)per-range font size and baseline shift
src/input/editor/display_map/scaled_text.rs (new)scale_pieces(), scaled_row(), row_box(): pieces of equal scale, a shared baseline, row height = max of the base box and every piece box (Small never shrinks a row)one rule for wrapper and painter
src/input/editor/display_map/text_wrapper.rs, wrap_map.rs, display_map.rsset_line_height(), wrap measures every scale piece at its own size, rows taller than the line height are stored in LineItem.blocks, _update(.., row_heights)wrap width and row tops follow the real glyph sizes
src/input/editor/display_map/inline_line.rsInlineFragment.placement (paint offset and height), InputLine.inline_offsetfragments of a scaled row paint on one baseline; atomic tokens sit on it too
src/input/base/element.rsscale_font(), push_text_fragments(); layout_lines / layout_token_lines build InputLine::inline rows for rows with scaled pieces, prepaint_tokens adds inline_offset, prepaint sets the wrapper line heightrows without scaled pieces keep the single ShapedLine path

Limits

  • Syntax-highlight (tree-sitter / LSP) bold or italic still wraps with the base font; only decorations feed wrapping.
  • Hanging-indent markers are dropped by an edit inside them; the app sets them again on change.
  • The unwrapped longest-line width (soft wrap off) ignores font overrides.
  • Scaled text needs a multi-line input; an empty line has no range to scale and stays one line high.
  • The caret is as tall as its row, not as tall as the glyph at the caret.
  • Block tokens are textarea-only and need soft wrap: no folds, line numbers, ghost text or touch handles. Without soft wrap a block token shares its row with text.

Re-apply on a gpui-kit upgrade

1. Check the new gpui-base version pinned by gpui-kit. 2. git diff <vendor commit> HEAD -- vendor/gpui-base > /tmp/gpui-base.patch (vendor commit: chore: vendor gpui-base 0.7.1 unchanged). 3. Replace vendor/gpui-base with the new registry source (~/.cargo/registry/src/*/gpui-base-<ver>/, drop .cargo-ok), commit it alone. 4. git apply -3 /tmp/gpui-base.patch, fix conflicts. 5. cargo test --manifest-path vendor/gpui-base/Cargo.toml --lib -- input and cargo build -p app; Cargo.lock must show gpui-base without source. 6. Delete this folder and the [patch] entry once upstream ships the features.

Source
1# gpui-base 0.7.1 patches
2
3Upstream: crates.io `gpui-base 0.7.1` (git `87d10ae5`, `crates/base`). Wired in via `[patch.crates-io]` in the root `Cargo.toml`.
4
5## Changed files
6
7| File | Change | Why |
8|---|---|---|
9| `Cargo.toml` | empty `[workspace]` table at the end | `cargo test --manifest-path vendor/gpui-base/Cargo.toml` works inside the app workspace (and nested worktrees) |
10| `src/input/editor/decorations.rs` | `TextDecoration.font_family`, `with_font_family()`, `FontOverride` (family, weight, style), `font_override_spans()` reading `font_family` + `style.font_weight` / `style.font_style`, `adjust_range_for_edit` made `pub(crate)`, doc on layering | font per byte range; first collection / item wins per property |
11| `src/input/editor/display_map/text_wrapper.rs` | `font_overrides` on `TextWrapper`, `split_run_by_font_overrides()`, `set_font_overrides()` / `adjust_font_overrides()`, `measured_wrap_boundaries` measures by range, shared `changed_ranges()` / `rewrap_rows_of()` | soft wrap measures mono / bold / italic ranges in their own font |
12| `src/input/editor/display_map/wrap_map.rs`, `display_map.rs`, `mod.rs` | pass-through for `set_font_overrides`, export `split_run_by_font_overrides` | plumbing |
13| `src/input/base/element.rs` | prepaint pushes font-override spans into the display map; render runs split by font override | glyphs, caret, selection and hit testing use the same shaped runs |
14| `src/input/base/state.rs` | `set_hanging_indents(markers)` on multi-line states (textarea and editor) | list lines: continuation rows start under the text after `•`, `◦`, `12.` |
15| `src/input/editor/display_map/text_wrapper.rs` | `hanging_indents` on `TextWrapper`, `hanging_indent_at()`, `measured_wrap_boundaries(.., hanging_indent, ..)`, `shift_span()` shared with inline metrics; a line with a marker always wraps as `WrappingIndent::Same` | wrap continuation rows at `wrap_width - marker width`; the existing `LineItem.indent` / `LineLayout.wrap_indent` path then shifts rendering, caret, selection, hit testing and up/down moves |
16| `src/input/editor/display_map/wrap_map.rs`, `display_map.rs` | pass-through for `set_hanging_indents`, adjust on edit | plumbing |
17| `src/input/base/kind.rs` | `TextareaExtras` (text + range decorations) as `TextareaMode::Extras`; edit tracking and reset hooks; sealed `DecoratedMode` trait for both multi-line modes | decorations on `TextareaState` (composer stays a textarea) |
18| `src/input/editor/decorations.rs` | `TextDecorationCollection<M = EditorMode>`, `RangeDecorationCollection<M = EditorMode>`, `create_*_collection` on `impl<M: DecoratedMode>`; `DecorationCollections` / `TrackedDecoration` `pub` + `#[doc(hidden)]` | same API on textarea and editor; default type param keeps editor code unchanged |
19| `src/input/editor/mod.rs`, `src/input/mod.rs` | doc no longer says decorations are editor-only; export `DecoratedMode`, `TextareaExtras` | docs, API |
20| `src/input/editor/display_map/text_wrapper.rs` | lines with inline tokens wrap through `measured_wrap_boundaries` too (`atomic` token ranges, token width + shaped text segments) instead of gpui's `LineWrapper` | mention lines honour font overrides and hanging indent |
21| `src/input/base/state.rs`, `src/input/editor/display_map/*`, `src/input/base/element.rs` | `set_line_indents(Vec<(line start, Pixels)>)`: every row of a line starts at its indent and wraps that much earlier; `LineLayout.first_indent` feeds caret, selection, hit testing and up/down; combines with a hanging indent; without one, continuation rows start at the line indent, not under leading spaces | nested list levels, quote gap and code padding without padding characters in the text |
22| `src/input/editor/decorations.rs` | `RangeDecorationStyle::{Pill, Block, Bar}`, `RangeDecoration::with_border()` / `with_radius()`; Block and Bar keep empty ranges (`TrackedDecoration::keeps_empty`) and the index finds them | rounded inline code pills, full-width code block fill, quote bar; a block over one empty line |
23| `src/input/base/element.rs` | `layout_range_decoration_quads()` paints pills, blocks and bars as quads below the fills | rounded corners and borders, which paths cannot draw |
24| `src/input/base/state.rs` | `apply_edits(&[(Range, String)])` on all states | several edits in one undo step without touching inline tokens between them |
25| `src/input/base/inline_tokens.rs`, `src/input/base/token_presentation.rs` | `InlineToken::block()` / `is_block()` (part of Hash and Eq), `InlineTokenContext::is_block()`, token layout cache keeps a `Size` per token (`sizes`) | a token that sits alone on its own row at its rendered height, e.g. an image preview in the composer |
26| `src/input/editor/display_map/text_wrapper.rs` | `InlineMetric { range, width, height }` replaces `(Range, Pixels)`; `measured_wrap_boundaries(.., forced, ..)` ends a row at each block token edge; `LineItem.blocks`, `LineSummary.block_rows` / `block_height`, `BlockExtent` dimension; `TextWrapper::row_top` / `row_height` / `row_at_y` / `content_height`; `LineLayout::row_top` / `row_height` / `row_at_y`; `InputLine.height` | rows are no longer uniform: a row that is exactly one block token has the token's height, lookups stay O(log n) |
27| `src/input/editor/display_map/display_map.rs`, `wrap_map.rs`, `mod.rs` | `DisplayMap::row_top` / `row_height` / `row_at_y` / `content_height` / `content_rows`, `InlineMetric` plumbing and export | plumbing |
28| `src/input/base/element.rs` | block tokens measured with `MinContent` height (always, also off-screen); caret top and height, selection corners, Block / Bar decoration height, visible range, scroll size and token placement use the row helpers | caret, selection and paint follow the taller row |
29| `src/input/base/state.rs`, `movement.rs`, `mode.rs` | `scroll_to`, hit testing, IME bounds, `line_and_position_for_offset` and Up / Down use the row helpers; `update_auto_grow(display_map, line_height)` counts `content_rows` | click, scroll and arrow keys land on the right row; auto grow fits the image |
30| `src/input/base/mode.rs`, `element.rs` | `update_auto_grow` lets the auto-grow height exceed `max_rows` by the rows block tokens add, up to `BLOCK_GROWTH_FACTOR` (2) times `max_rows`; the textarea min height uses `mode.rows()` | an image does not use up the text row budget |
31| `src/input/base/element.rs` | `layout_cursors` also follows the caret on a frame where an auto-grow viewport changed height (`viewport_changed`), not only when the selection changed | text typed after a block token, or loaded content, stays visible while the viewport is still growing |
32| `src/input/editor/decorations.rs` | `TextDecoration.font_scale` / `baseline_shift`, `with_font_scale()` / `with_baseline_shift()`, `FontOverride.scale` / `raise`, `product_spans()` (scales multiply, first raise wins) | per-range font size and baseline shift |
33| `src/input/editor/display_map/scaled_text.rs` (new) | `scale_pieces()`, `scaled_row()`, `row_box()`: pieces of equal scale, a shared baseline, row height = max of the base box and every piece box (Small never shrinks a row) | one rule for wrapper and painter |
34| `src/input/editor/display_map/text_wrapper.rs`, `wrap_map.rs`, `display_map.rs` | `set_line_height()`, wrap measures every scale piece at its own size, rows taller than the line height are stored in `LineItem.blocks`, `_update(.., row_heights)` | wrap width and row tops follow the real glyph sizes |
35| `src/input/editor/display_map/inline_line.rs` | `InlineFragment.placement` (paint offset and height), `InputLine.inline_offset` | fragments of a scaled row paint on one baseline; atomic tokens sit on it too |
36| `src/input/base/element.rs` | `scale_font()`, `push_text_fragments()`; `layout_lines` / `layout_token_lines` build `InputLine::inline` rows for rows with scaled pieces, `prepaint_tokens` adds `inline_offset`, prepaint sets the wrapper line height | rows without scaled pieces keep the single `ShapedLine` path |
37
38## Limits
39
40- Syntax-highlight (tree-sitter / LSP) bold or italic still wraps with the base font; only decorations feed wrapping.
41- Hanging-indent markers are dropped by an edit inside them; the app sets them again on change.
42- The unwrapped longest-line width (soft wrap off) ignores font overrides.
43- Scaled text needs a multi-line input; an empty line has no range to scale and stays one line high.
44- The caret is as tall as its row, not as tall as the glyph at the caret.
45- Block tokens are textarea-only and need soft wrap: no folds, line numbers, ghost text or touch handles. Without soft wrap a block token shares its row with text.
46
47## Re-apply on a gpui-kit upgrade
48
491. Check the new `gpui-base` version pinned by `gpui-kit`.
502. `git diff <vendor commit> HEAD -- vendor/gpui-base > /tmp/gpui-base.patch` (vendor commit: `chore: vendor gpui-base 0.7.1 unchanged`).
513. Replace `vendor/gpui-base` with the new registry source (`~/.cargo/registry/src/*/gpui-base-<ver>/`, drop `.cargo-ok`), commit it alone.
524. `git apply -3 /tmp/gpui-base.patch`, fix conflicts.
535. `cargo test --manifest-path vendor/gpui-base/Cargo.toml --lib -- input` and `cargo build -p app`; `Cargo.lock` must show `gpui-base` without `source`.
546. Delete this folder and the `[patch]` entry once upstream ships the features.