Skip to content

Structure buffer APIs in terms of strings and byte counts instead of chars and character counts - #70

Merged
as-cii merged 18 commits into
masterfrom
optimizations
May 20, 2021
Merged

Structure buffer APIs in terms of strings and byte counts instead of chars and character counts#70
as-cii merged 18 commits into
masterfrom
optimizations

Conversation

@maxbrunsfeld

@maxbrunsfeld maxbrunsfeld commented May 19, 2021

Copy link
Copy Markdown
Collaborator
  • Change Buffer APIs to panic on out-of-bounds access, instead of returning Result
  • Introduce text-access iterator APIs that return string chunks instead of chars
    • Rope::chunks_in_range
    • FoldMap::chunks_at
    • DisplayMap::chunks_at
  • Stop counting characters in the Rope
  • Change FontSystem::layout_str to accept and return runs with byte ranges instead of character counts
  • Change FileFinder to pass byte indices to string layout methods
  • Change Label element to handle byte indices for highlights
  • Decide how to deal with rightmost_point

as-cii and others added 17 commits May 20, 2021 12:47
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Get the FoldMap randomized tests passing. This also required adding
a test-only FoldMap::prev_char_boundary method.
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
Introduce `clip_point` and `clip_offset` methods on `Rope`, `Buffer`, and `FoldMap`.

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
* Interpret ranges as byte ranges for incoming runs
* Return glyphs whose indices are byte offsets
This fixes a couple of tests that were panicking due to an out-of-bound
access.
@as-cii
as-cii merged commit 86199c5 into master May 20, 2021
@as-cii
as-cii deleted the optimizations branch May 20, 2021 11:02
Anthony-Eid pushed a commit to Anthony-Eid/zed that referenced this pull request Dec 5, 2024
* dap_adapters: add gdb

* debug: Add debug zed with gdb task
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
Structure buffer APIs in terms of strings and byte counts instead of chars and character counts
ShalashaskaOcelot pushed a commit to ShalashaskaOcelot/zed that referenced this pull request Aug 13, 2026
Test results from 2026-08-11. Bugs zed-industries#7, zed-industries#66, zed-industries#67, zed-industries#68, zed-industries#70 and zed-industries#72 confirmed
fixed and removed; zed-industries#64 failed and stays open with the finding recorded; zed-industries#73's
repro is confirmed on Windows. Three fixes here.

zed-industries#69 (column titles wrapping their last character) was NOT fixed by the previous
attempt, and that attempt was aimed at the wrong layer. Measuring headers
semibold was a real discrepancy and stays, but the cause is that the table
renders at a different font SIZE from the one it measures with: ui's
font_buffer sets only the font family, so the size stayed ambient while
TableView::new measured against buffer_font_size. Every glyph then rendered a
fraction wider than measured, and the error accumulates with string length —
invisible on a 15-character title, just past the padding slack on a
16-character one, which is exactly the reported Column_number_9-fits,
Column_number_10-wraps threshold. The rendered size is now pinned to the
measured one.

zed-industries#74: a notebook whose file was deleted while Zed was closed didn't restore at
all, taking any unsaved changes with it. Nothing to do with deletion handling —
open_buffer deliberately returns an empty buffer for a path with no entry, so
the notebook parses, but try_open then demanded a worktree entry id and a
deleted file has none. That id was already optional on NotebookItem (it is only
a fallback for entry_id, which re-resolves from the path), so nothing needed it
to be present.

zed-industries#75: a restored untitled notebook showed no dirty marker until the next
keystroke. Same trap phase 69 fixed for file-backed notebooks and missed here:
rebuilding a notebook from stored JSON makes those cells their own baseline, so
it reads as clean. Contents are only stored when there ARE unsaved changes, so a
restored untitled notebook is unsaved by definition and now says so.

Also filed zed-industries#76: restoring unsaved changes over a file edited elsewhere gives no
notification. The conflict flag may well be set correctly and simply invisible
until save time, which is the first thing to check — the two possible causes
need different fixes, so nothing is attempted yet.

Backlogged from zed-industries#72's confirmation: a restart should read Restarting → Idle,
not Restarting → Starting → Idle.

Verified: clippy clean, 57 repl tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JkvYRuX9r6PmLXpxNie2R7
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.

2 participants