Skip to content

editor: Reuse display-map cursors when converting word diffs - #58658

Merged
Veykril merged 1 commit into
mainfrom
push-xynunytrswuk
Jun 17, 2026
Merged

editor: Reuse display-map cursors when converting word diffs#58658
Veykril merged 1 commit into
mainfrom
push-xynunytrswuk

Conversation

@Veykril

@Veykril Veykril commented Jun 5, 2026

Copy link
Copy Markdown
Member

layout_word_diff_highlights converted each visible word diff to display points via isomorphic_display_point_ranges_for_buffer_range, which walks the inlay/fold/tab/wrap/block trees from the root on every call. With many word diffs on screen this re-walks the same trees repeatedly each frame.

Add a DisplayPointConverter that holds a forward-only cursor for each display-map layer (mirroring the cursor reuse already done in BlockMap::sync) so consecutive conversions amortize to near-constant work. New forward cursors BufferOffsetToInlayPointCursor and BlockPointCursor back the inlay and block layers; the fold/tab/wrap layers reuse existing cursors. Each cursor gains a cheap reset() that delegates to the underlying SumTree cursor; the converter resets its cursors if an input range starts before the previous one ended, so it stays correct for overlapping inputs (e.g. the base and buffer word diffs of an inline modified hunk).

layout_word_diff_highlights now sorts the visible word diffs and feeds them through a single converter. isomorphic_display_point_ranges_for_buffer_range is reimplemented on top of the converter to keep one code path.

Release Notes:

  • Improved scrolling performance in diff views containing large hunks

layout_word_diff_highlights converted each visible word diff to display
points via isomorphic_display_point_ranges_for_buffer_range, which walks
the inlay/fold/tab/wrap/block trees from the root on every call. With many
word diffs on screen this re-walks the same trees repeatedly each frame.

Add a DisplayPointConverter that holds a forward-only cursor for each
display-map layer (mirroring the cursor reuse already done in
BlockMap::sync) so consecutive conversions amortize to near-constant work.
New forward cursors BufferOffsetToInlayPointCursor and BlockPointCursor
back the inlay and block layers; the fold/tab/wrap layers reuse existing
cursors. Each cursor gains a cheap reset() that delegates to the
underlying SumTree cursor; the converter resets its cursors if an input
range starts before the previous one ended, so it stays correct for
overlapping inputs (e.g. the base and buffer word diffs of an inline
modified hunk).

layout_word_diff_highlights now sorts the visible word diffs and feeds
them through a single converter. isomorphic_display_point_ranges_for_buffer_range
is reimplemented on top of the converter to keep one code path.

Release Notes:

- Improved scrolling performance in diff views containing large hunks
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 5, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jun 5, 2026
@Veykril
Veykril marked this pull request as ready for review June 12, 2026 09:43
@Veykril
Veykril requested a review from Anthony-Eid June 12, 2026 10:12
@Veykril
Veykril added this pull request to the merge queue Jun 17, 2026
Merged via the queue into main with commit 489c880 Jun 17, 2026
46 checks passed
@Veykril
Veykril deleted the push-xynunytrswuk branch June 17, 2026 08:42
This was referenced Jun 18, 2026
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ustries#58658)

layout_word_diff_highlights converted each visible word diff to display
points via isomorphic_display_point_ranges_for_buffer_range, which walks
the inlay/fold/tab/wrap/block trees from the root on every call. With
many word diffs on screen this re-walks the same trees repeatedly each
frame.

Add a DisplayPointConverter that holds a forward-only cursor for each
display-map layer (mirroring the cursor reuse already done in
BlockMap::sync) so consecutive conversions amortize to near-constant
work. New forward cursors BufferOffsetToInlayPointCursor and
BlockPointCursor back the inlay and block layers; the fold/tab/wrap
layers reuse existing cursors. Each cursor gains a cheap reset() that
delegates to the underlying SumTree cursor; the converter resets its
cursors if an input range starts before the previous one ended, so it
stays correct for overlapping inputs (e.g. the base and buffer word
diffs of an inline modified hunk).

layout_word_diff_highlights now sorts the visible word diffs and feeds
them through a single converter.
isomorphic_display_point_ranges_for_buffer_range is reimplemented on top
of the converter to keep one code path.

Release Notes:

- Improved scrolling performance in diff views containing large hunks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants