From 3ae0da3acda101311797bf0f2efd4088e3e93d42 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Tue, 3 Feb 2026 22:58:42 -0500 Subject: [PATCH] git: Use `WrapPointCursor` for spacer blocks calculation (#48315) `spacer_blocks` is an ideal place to drop `WrapPointCursor` since a large part of what it does it to convert an increasing sequence of `MultiBufferPoint` into `WrapPoint`. Release Notes: - N/A --- crates/editor/src/display_map/block_map.rs | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 7c926cbfbb46845833688cbb854eaa1af468bb1d..b85f13e3a67bffb6cffb63abe792487045a1f770 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -1100,10 +1100,29 @@ impl BlockMap { bounds, ); - let determine_spacer = |our_point: Point, their_point: Point, delta: i32| { - let our_wrap = wrap_snapshot.make_wrap_point(our_point, Bias::Left).row(); - let companion_wrap = companion_snapshot - .make_wrap_point(their_point, Bias::Left) + let mut our_inlay_point_cursor = wrap_snapshot.inlay_point_cursor(); + let mut our_fold_point_cursor = wrap_snapshot.fold_point_cursor(); + let mut our_tab_point_cursor = wrap_snapshot.tab_point_cursor(); + let mut our_wrap_point_cursor = wrap_snapshot.wrap_point_cursor(); + + let mut companion_inlay_point_cursor = companion_snapshot.inlay_point_cursor(); + let mut companion_fold_point_cursor = companion_snapshot.fold_point_cursor(); + let mut companion_tab_point_cursor = companion_snapshot.tab_point_cursor(); + let mut companion_wrap_point_cursor = companion_snapshot.wrap_point_cursor(); + + let mut determine_spacer = |our_point: Point, their_point: Point, delta: i32| { + let our_wrap = our_wrap_point_cursor + .map(our_tab_point_cursor.map( + our_fold_point_cursor.map(our_inlay_point_cursor.map(our_point), Bias::Left), + )) + .row(); + let companion_wrap = companion_wrap_point_cursor + .map( + companion_tab_point_cursor.map( + companion_fold_point_cursor + .map(companion_inlay_point_cursor.map(their_point), Bias::Left), + ), + ) .row(); let new_delta = companion_wrap.0 as i32 - our_wrap.0 as i32; @@ -1118,8 +1137,6 @@ impl BlockMap { let mut result = Vec::new(); - // old approach: buffer_diff computed the patch, and then passed a chosen sequence of points through it, returning the results - // new approach: buffer_diff gives us the patch directly, and then we pass through the points we are interested in for excerpt in patches { let mut source_points = (excerpt.edited_range.start.row..=excerpt.edited_range.end.row) .map(|row| MultiBufferPoint::new(row, 0))