From e231321655a170ca30438c1040da053432885b6d Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Tue, 3 Dec 2024 22:20:25 -0800 Subject: [PATCH] Fix panic in update_ime_position (#21510) This can call back into the app, so must be done when the platform lock is not held. Release Notes: - Fixes a (rare) panic when changing tab --- crates/gpui/src/platform/mac/window.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 9266f81f74a80..8ea7ebd4d5fe6 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -1111,10 +1111,16 @@ impl PlatformWindow for MacWindow { } fn update_ime_position(&self, _bounds: Bounds) { - unsafe { - let input_context: id = msg_send![class!(NSTextInputContext), currentInputContext]; - let _: () = msg_send![input_context, invalidateCharacterCoordinates]; - } + let executor = self.0.lock().executor.clone(); + executor + .spawn(async move { + unsafe { + let input_context: id = + msg_send![class!(NSTextInputContext), currentInputContext]; + let _: () = msg_send![input_context, invalidateCharacterCoordinates]; + } + }) + .detach() } }