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:
co-authored by
Mikayla Maki
parent
e6d5f4406f
commit
8e8927db4b
+21
-10
@@ -76,8 +76,8 @@ use gpui::{
|
||||
FocusOutEvent, FocusableView, FontId, FontWeight, HighlightStyle, Hsla, InteractiveText,
|
||||
KeyContext, ListSizingBehavior, Model, MouseButton, PaintQuad, ParentElement, Pixels, Render,
|
||||
SharedString, Size, StrikethroughStyle, Styled, StyledText, Subscription, Task, TextStyle,
|
||||
UnderlineStyle, UniformListScrollHandle, View, ViewContext, ViewInputHandler, VisualContext,
|
||||
WeakFocusHandle, WeakView, WindowContext,
|
||||
UTF16Selection, UnderlineStyle, UniformListScrollHandle, View, ViewContext, ViewInputHandler,
|
||||
VisualContext, WeakFocusHandle, WeakView, WindowContext,
|
||||
};
|
||||
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
||||
use hover_popover::{hide_hover, HoverState};
|
||||
@@ -2365,6 +2365,8 @@ impl Editor {
|
||||
show_completions: bool,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
cx.invalidate_character_coordinates();
|
||||
|
||||
// Copy selections to primary selection buffer
|
||||
#[cfg(target_os = "linux")]
|
||||
if local {
|
||||
@@ -11839,12 +11841,12 @@ impl Editor {
|
||||
|
||||
let snapshot = buffer.read(cx).snapshot();
|
||||
let range = self
|
||||
.selected_text_range(cx)
|
||||
.and_then(|selected_range| {
|
||||
if selected_range.is_empty() {
|
||||
.selected_text_range(false, cx)
|
||||
.and_then(|selection| {
|
||||
if selection.range.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(selected_range)
|
||||
Some(selection.range)
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| 0..snapshot.len());
|
||||
@@ -12796,15 +12798,24 @@ impl ViewInputHandler for Editor {
|
||||
)
|
||||
}
|
||||
|
||||
fn selected_text_range(&mut self, cx: &mut ViewContext<Self>) -> Option<Range<usize>> {
|
||||
fn selected_text_range(
|
||||
&mut self,
|
||||
ignore_disabled_input: bool,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<UTF16Selection> {
|
||||
// Prevent the IME menu from appearing when holding down an alphabetic key
|
||||
// while input is disabled.
|
||||
if !self.input_enabled {
|
||||
if !ignore_disabled_input && !self.input_enabled {
|
||||
return None;
|
||||
}
|
||||
|
||||
let range = self.selections.newest::<OffsetUtf16>(cx).range();
|
||||
Some(range.start.0..range.end.0)
|
||||
let selection = self.selections.newest::<OffsetUtf16>(cx);
|
||||
let range = selection.range();
|
||||
|
||||
Some(UTF16Selection {
|
||||
range: range.start.0..range.end.0,
|
||||
reversed: selection.reversed,
|
||||
})
|
||||
}
|
||||
|
||||
fn marked_text_range(&self, cx: &mut ViewContext<Self>) -> Option<Range<usize>> {
|
||||
|
||||
Reference in New Issue
Block a user