diff --git a/crates/gpui_linux/src/linux/wayland/client.rs b/crates/gpui_linux/src/linux/wayland/client.rs index ac637d3fc4..256875bed1 100644 --- a/crates/gpui_linux/src/linux/wayland/client.rs +++ b/crates/gpui_linux/src/linux/wayland/client.rs @@ -388,7 +388,7 @@ impl WaylandClientStatePtr { pub fn update_ime_position(&self, bounds: Bounds) { let client = self.get_client(); let state = client.borrow_mut(); - if state.composing || state.text_input.is_none() || state.pre_edit_text.is_some() { + if state.text_input.is_none() || state.pre_edit_text.is_some() { return; } diff --git a/crates/terminal_view/src/terminal_element.rs b/crates/terminal_view/src/terminal_element.rs index cd0ed9241f..b74d28593d 100644 --- a/crates/terminal_view/src/terminal_element.rs +++ b/crates/terminal_view/src/terminal_element.rs @@ -1349,7 +1349,6 @@ impl Element for TerminalElement { }; let terminal_input_handler = TerminalInputHandler { - terminal: self.terminal.clone(), terminal_view: self.terminal_view.clone(), cursor_bounds: layout.ime_cursor_bounds.map(|bounds| bounds + origin), workspace: self.workspace.clone(), @@ -1510,7 +1509,6 @@ impl IntoElement for TerminalElement { } struct TerminalInputHandler { - terminal: Entity, terminal_view: Entity, workspace: WeakEntity, cursor_bounds: Option>, @@ -1521,22 +1519,15 @@ impl InputHandler for TerminalInputHandler { &mut self, _ignore_disabled_input: bool, _: &mut Window, - cx: &mut App, + _cx: &mut App, ) -> Option { - if self - .terminal - .read(cx) - .last_content - .mode - .contains(Modes::ALT_SCREEN) - { - None - } else { - Some(UTF16Selection { - range: 0..0, - reversed: false, - }) - } + // Always return a valid selection for IME positioning, + // even in ALT_SCREEN mode (fullscreen TUI apps like opencode, vim, etc.) + // The terminal still has a cursor position that should be used for IME candidate window placement. + Some(UTF16Selection { + range: 0..0, + reversed: false, + }) } fn marked_text_range( diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index ea888d564c..3b1e6db97f 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -1129,6 +1129,7 @@ fn subscribe_for_terminal_events( match event { Event::Wakeup => { cx.notify(); + window.invalidate_character_coordinates(); cx.emit(Event::Wakeup); cx.emit(ItemEvent::UpdateTab); cx.emit(SearchEvent::MatchesInvalidated);