editor: Fix panics in CursorPosition::update_position (#41237)

Fixes a regression introduced in
https://github.com/zed-industries/zed/pull/39857. As for the exact
reason this causes this issue I am not yet sure will investigate (as per
the todos in code)

Fixes ZED-23R

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Lukas Wirth
2025-10-27 08:26:39 +00:00
committed by GitHub
parent edf2ec7d4c
commit ae3abf50d8
14 changed files with 207 additions and 178 deletions
@@ -69,6 +69,8 @@ impl From<CustomBlockId> for ElementId {
}
}
/// A zero-indexed point in a text buffer consisting of a row and column
/// adjusted for inserted blocks, wrapped rows, tabs, folds and inlays.
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
pub struct BlockPoint(pub Point);
@@ -80,11 +82,16 @@ struct WrapRow(u32);
pub type RenderBlock = Arc<dyn Send + Sync + Fn(&mut BlockContext) -> AnyElement>;
/// Where to place a block.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum BlockPlacement<T> {
/// Place the block above the given position.
Above(T),
/// Place the block below the given position.
Below(T),
/// Place the block next the given position.
Near(T),
/// Replace the given range of positions with the block.
Replace(RangeInclusive<T>),
}