Implement character index for point (#23989)
Fixes #22939 Fixes #23970 Supersedes https://github.com/zed-industries/zed/pull/23469 Release Notes: - Fixed a bug where Zed could crash with certain input sources on macOS --------- Co-authored-by: Louis Brunner <louis.brunner.fr@gmail.com> Co-authored-by: ben <ben@zed.dev>
This commit is contained in:
parent
7da60995cc
commit
cfe0932c0a
9 changed files with 221 additions and 129 deletions
|
@ -62,6 +62,14 @@ pub trait EntityInputHandler: 'static + Sized {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<Bounds<Pixels>>;
|
||||
|
||||
/// See [`InputHandler::character_index_for_point`] for details
|
||||
fn character_index_for_point(
|
||||
&mut self,
|
||||
point: crate::Point<Pixels>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<usize>;
|
||||
}
|
||||
|
||||
/// The canonical implementation of [`PlatformInputHandler`]. Call [`Window::handle_input`]
|
||||
|
@ -158,4 +166,15 @@ impl<V: EntityInputHandler> InputHandler for ElementInputHandler<V> {
|
|||
view.bounds_for_range(range_utf16, self.element_bounds, window, cx)
|
||||
})
|
||||
}
|
||||
|
||||
fn character_index_for_point(
|
||||
&mut self,
|
||||
point: crate::Point<Pixels>,
|
||||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> Option<usize> {
|
||||
self.view.update(cx, |view, cx| {
|
||||
view.character_index_for_point(point, window, cx)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue