From f3a5ebc31501c4f46c5fe0478759ce21b6249c13 Mon Sep 17 00:00:00 2001 From: Dino Date: Fri, 31 Oct 2025 15:04:54 +0000 Subject: [PATCH] vim: Only focus when associated editor is also focused (#41487) Update `Vim::activate` to ensure that the `Vim.focused` method is only called if the associated editor is also focused. This ensures that the `VimEvent::Focused` event is only emitted when the editor is actually focused, preventing a bug where, after starting Zed, Vim's mode indicator would show that the mode was `Insert` even though it was in `Normal` mode in the main editor. Closes #41353 Release Notes: - Fixed vim's mode being shown as `Inserted` right after opening Zed Co-authored-by: Conrad Irwin --- crates/vim/src/vim.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 91ce66d43e76f3a40a5e074f01527953def1b188..3310c1dab1ac3c05bc24aa1b56f94dcfa22511f8 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -944,9 +944,11 @@ impl Vim { change_list::register(editor, cx); digraph::register(editor, cx); - cx.defer_in(window, |vim, window, cx| { - vim.focused(false, window, cx); - }) + if editor.is_focused(window) { + cx.defer_in(window, |vim, window, cx| { + vim.focused(false, window, cx); + }) + } }) }