Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Query `rect_for_text_range` on focused view instead of root element
Antonio Scandurrac872f581d14a
diff --git a/crates/gpui/src/app/window.rs b/crates/gpui/src/app/window.rsindex 30d58cdd726..cfcef626dfa 100644--- a/crates/gpui/src/app/window.rs+++ b/crates/gpui/src/app/window.rs@@ -965,10 +965,10 @@ impl<'a> WindowContext<'a> {}pub fn rect_for_text_range(&self, range_utf16: Range<usize>) -> Option<RectF> {- let root_view_id = self.window.root_view().id();+ let focused_view_id = self.window.focused_view_id?;self.window.rendered_views- .get(&root_view_id)?+ .get(&focused_view_id)?.rect_for_text_range(range_utf16, self).log_err().flatten()diff --git a/crates/gpui/src/app/window_input_handler.rs b/crates/gpui/src/app/window_input_handler.rsindex 938dbe1a039..8ee9f7eeff5 100644--- a/crates/gpui/src/app/window_input_handler.rs+++ b/crates/gpui/src/app/window_input_handler.rs@@ -84,8 +84,8 @@ impl InputHandler for WindowInputHandler {fn rect_for_range(&self, range_utf16: Range<usize>) -> Option<RectF> {self.app- .borrow_mut()- .update_window(self.window_id, |cx| cx.rect_for_text_range(range_utf16))+ .borrow()+ .read_window(self.window_id, |cx| cx.rect_for_text_range(range_utf16)).flatten()}}