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

@ -5,7 +5,7 @@ use gpui::{
HighlightStyle, Hitbox, Hsla, InputHandler, InteractiveElement, Interactivity, IntoElement,
LayoutId, Model, ModelContext, ModifiersChangedEvent, MouseButton, MouseMoveEvent, Pixels,
Point, ShapedLine, StatefulInteractiveElement, StrikethroughStyle, Styled, TextRun, TextStyle,
UnderlineStyle, View, WeakView, WhiteSpace, WindowContext, WindowTextSystem,
UTF16Selection, UnderlineStyle, View, WeakView, WhiteSpace, WindowContext, WindowTextSystem,
};
use itertools::Itertools;
use language::CursorShape;
@ -976,7 +976,11 @@ struct TerminalInputHandler {
}
impl InputHandler for TerminalInputHandler {
fn selected_text_range(&mut self, cx: &mut WindowContext) -> Option<std::ops::Range<usize>> {
fn selected_text_range(
&mut self,
_ignore_disabled_input: bool,
cx: &mut WindowContext,
) -> Option<UTF16Selection> {
if self
.terminal
.read(cx)
@ -986,7 +990,10 @@ impl InputHandler for TerminalInputHandler {
{
None
} else {
Some(0..0)
Some(UTF16Selection {
range: 0..0,
reversed: false,
})
}
}
@ -1014,6 +1021,8 @@ impl InputHandler for TerminalInputHandler {
self.workspace
.update(cx, |this, cx| {
cx.invalidate_character_coordinates();
let telemetry = this.project().read(cx).client().telemetry().clone();
telemetry.log_edit_event("terminal");
})