Query rect_for_text_range on focused view instead of root element (#2564)

This was causing IME input to be drawn in the wrong place when there
were splits or panels in the window.

Release Notes:

- Fixed a bug that was causing IME input to sometimes be rendered in the
wrong position.
This commit is contained in:
Antonio Scandurra 2023-06-05 12:11:35 +02:00 committed by GitHub
commit 0ed8bbc818
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View file

@ -965,10 +965,10 @@ impl<'a> WindowContext<'a> {
} }
pub fn rect_for_text_range(&self, range_utf16: Range<usize>) -> Option<RectF> { 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 self.window
.rendered_views .rendered_views
.get(&root_view_id)? .get(&focused_view_id)?
.rect_for_text_range(range_utf16, self) .rect_for_text_range(range_utf16, self)
.log_err() .log_err()
.flatten() .flatten()

View file

@ -84,8 +84,8 @@ impl InputHandler for WindowInputHandler {
fn rect_for_range(&self, range_utf16: Range<usize>) -> Option<RectF> { fn rect_for_range(&self, range_utf16: Range<usize>) -> Option<RectF> {
self.app self.app
.borrow_mut() .borrow()
.update_window(self.window_id, |cx| cx.rect_for_text_range(range_utf16)) .read_window(self.window_id, |cx| cx.rect_for_text_range(range_utf16))
.flatten() .flatten()
} }
} }