linux: Fix IME panel position while enumerating input methods (#12495)

Release Notes:

- N/A

This updates the IME position every time the selection changes, this is
probably only useful when you enumerate languages with your IME.

TODO:
- ~There is a rare chance that the ime panel is not updated because the
window input handler is None.~
- ~Update IME panel in vim mode.~
- ~Update IME panel when leaving Buffer search input.~

---------

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
Fernando Tagawa 2024-08-28 23:58:40 -03:00 committed by GitHub
parent e6d5f4406f
commit 8e8927db4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 244 additions and 55 deletions

View file

@ -552,7 +552,7 @@ impl BufferSearchBar {
active_editor.search_bar_visibility_changed(false, cx);
active_editor.toggle_filtered_search_ranges(false, cx);
let handle = active_editor.focus_handle(cx);
cx.focus(&handle);
self.focus(&handle, cx);
}
cx.emit(Event::UpdateLocation);
cx.emit(ToolbarItemEvent::ChangeLocation(
@ -1030,7 +1030,7 @@ impl BufferSearchBar {
} else {
return;
};
cx.focus(&focus_handle);
self.focus(&focus_handle, cx);
cx.stop_propagation();
}
@ -1043,7 +1043,7 @@ impl BufferSearchBar {
} else {
return;
};
cx.focus(&focus_handle);
self.focus(&focus_handle, cx);
cx.stop_propagation();
}
@ -1081,6 +1081,12 @@ impl BufferSearchBar {
}
}
fn focus(&self, handle: &gpui::FocusHandle, cx: &mut ViewContext<Self>) {
cx.on_next_frame(|_, cx| {
cx.invalidate_character_coordinates();
});
cx.focus(handle);
}
fn toggle_replace(&mut self, _: &ToggleReplace, cx: &mut ViewContext<Self>) {
if let Some(_) = &self.active_searchable_item {
self.replace_enabled = !self.replace_enabled;
@ -1089,7 +1095,7 @@ impl BufferSearchBar {
} else {
self.query_editor.focus_handle(cx)
};
cx.focus(&handle);
self.focus(&handle, cx);
cx.notify();
}
}