From 3f80ac01278b273b5ebc6a4956ad1c215b185e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=B0=8F=E7=99=BD?= <364772080@qq.com> Date: Mon, 8 Sep 2025 22:44:19 +0800 Subject: [PATCH] macos: Fix menu bar flickering (#37707) Closes #37526 Release Notes: - Fixed menu bar flickering when using some IMEs on macOS. --- crates/zed/src/zed.rs | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index cb5cfea81a06fd27cb19d7f2e2cd845e9236ae2c..91ec021c44babb126cc33fad65131f100e285443 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -1317,15 +1317,31 @@ pub fn handle_keymap_file_changes( }) .detach(); - let mut current_layout_id = cx.keyboard_layout().id().to_string(); - cx.on_keyboard_layout_change(move |cx| { - let next_layout_id = cx.keyboard_layout().id(); - if next_layout_id != current_layout_id { - current_layout_id = next_layout_id.to_string(); - keyboard_layout_tx.unbounded_send(()).ok(); - } - }) - .detach(); + #[cfg(target_os = "windows")] + { + let mut current_layout_id = cx.keyboard_layout().id().to_string(); + cx.on_keyboard_layout_change(move |cx| { + let next_layout_id = cx.keyboard_layout().id(); + if next_layout_id != current_layout_id { + current_layout_id = next_layout_id.to_string(); + keyboard_layout_tx.unbounded_send(()).ok(); + } + }) + .detach(); + } + + #[cfg(not(target_os = "windows"))] + { + let mut current_mapping = cx.keyboard_mapper().get_key_equivalents().cloned(); + cx.on_keyboard_layout_change(move |cx| { + let next_mapping = cx.keyboard_mapper().get_key_equivalents(); + if current_mapping.as_ref() != next_mapping { + current_mapping = next_mapping.cloned(); + keyboard_layout_tx.unbounded_send(()).ok(); + } + }) + .detach(); + } load_default_keymap(cx);