Skip to content

Pass scalar lengths and include colors when specifying styling runs during text layout - #71

Merged
nathansobo merged 4 commits into
masterfrom
simplify-text-layout
May 21, 2021
Merged

Pass scalar lengths and include colors when specifying styling runs during text layout#71
nathansobo merged 4 commits into
masterfrom
simplify-text-layout

Conversation

@nathansobo

Copy link
Copy Markdown
Contributor

This PR is laying the foundation for syntax highlighting.

It changes how we specify runs of styling when calling TextLayoutCache::layout_str. Previously, you would pass a runs argument of type &[Range<usize>, FontId]. Colors where specified separately when painting the line.

For syntax highlighting, we realized it would be helpful to unify our handling of colors and fonts in a single interface. So now you pass a ColorU in addition to the FontId as part of each run. We still ignore colors for the purposes of caching the text layouts by coalescing contiguous runs with the same font before calling into CoreText.

Additionally, rather than specifying a start and end range for each run, you now simply pass the run's length in bytes.

Also move from the runs being expressed as ranges to the runs being expressed as a sequence of contiguous scalar lengths.
@nathansobo
nathansobo merged commit eb345e7 into master May 21, 2021
@nathansobo
nathansobo deleted the simplify-text-layout branch May 21, 2021 20:40
Anthony-Eid pushed a commit to Anthony-Eid/zed that referenced this pull request Dec 5, 2024
* Add sync active debug line over collab

* Remove unused downcast

* Remove unused import
ShalashaskaOcelot pushed a commit to ShalashaskaOcelot/zed that referenced this pull request Aug 7, 2026
Five bugs from the phase 63/64 test round, all filed in bugs.md with analysis.

zed-industries#67 A vertical wheel dragged wide tables sideways while the notebook scrolled.
gpui applies a wheel's other-axis delta to an element that scrolls in only one
direction unless restrict_scroll_to_axis is set; the table now sets it, so it
answers only to horizontal input and vertical wheels pass through.

zed-industries#68 The horizontal scrollbar slid out from under the pointer when dragged: it
was applied to the same element that scrolls, so it was laid out in content
space and translated with the content. The scroll container is now a child of a
plain wrapper that carries the scrollbars, matching ui's data_table.

zed-industries#69 Column titles wrapped their last character even with room to spare. Headers
render semibold but every column width was measured at regular weight, leaving
each column a few pixels short of its own title. Titles are now measured
semibold.

zed-industries#70 Columns didn't line up row to row: in fill-width mode cells had grow factors
but no flex basis, so each cell started from its own content width and every row
distributed spare space differently. flex_basis(0) makes the split depend only
on the per-column grow factors.

zed-industries#72 Kernel status stuck on "Starting" until a cell ran. Kernels broadcast
status: starting as they come up, and that message can land after the launch
task has already installed the kernel as Running/Idle — overwriting it, with
nothing to correct it until the next execution. A connected kernel is past
starting, so that state is now ignored for a RunningKernel.

Also filed zed-industries#71 (a cell being edited stops accepting input once scrolled out of
view) undiagnosed, and backlogged a distinct "creating environment" state for
the kernel strip, which currently shows the misleading "Starting" during a
build.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JkvYRuX9r6PmLXpxNie2R7
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…t-layout

Pass scalar lengths and include colors when specifying styling runs during text layout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant