From 7315aada89c44e74cd08c31ecf168a1ce8322242 Mon Sep 17 00:00:00 2001 From: saberoueslati Date: Tue, 31 Mar 2026 07:28:13 +0100 Subject: [PATCH] git_ui: Fix branch picker stealing vim keys in Git panel (#52687) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Context When `vim_mode` is enabled, opening the branch selector popover in the Git panel and pressing `i`, `j`, `k`, or `x` triggered Git panel actions (`FocusEditor`, `SelectNext`, `ToggleStaged`, etc.) instead of reaching the picker's search field. The `"GitPanel && ChangesList"` keybinding block in `vim.json` matched whenever _any_ child of the git panel's focus handle was focused — including the branch picker popover — because `GitPanel::dispatch_context()` adds `ChangesList` based on `focus_handle.contains_focused()`, which is true for all children, not just the changes list itself. The branch picker's root element already sets `.key_context("GitBranchSelector")` (branch_picker.rs). GPUI's `Not` predicate evaluates against the entire context path, so adding `&& !GitBranchSelector` to the block's context suppresses all those bindings whenever the picker is open, and restores them exactly as before once it's closed. Closes #52617 Video of the manual test of the fix below : [Screencast from 2026-03-29 22-01-11.webm](https://github.com/user-attachments/assets/217e8e31-9bee-4e77-a7aa-0c094874ed9a) ## How to Review - `assets/keymaps/vim.json` : changed the `"GitPanel && ChangesList"` context string ,I added`&& !GitBranchSelector`. ## Self-Review Checklist - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the UI/UX checklist - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed branch picker in the Git panel stealing vim keystrokes (`i`, `j`, `k`, `x`) when vim mode is enabled --- assets/keymaps/vim.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index ae0a0dd0f1ef3ba99814b39db6ec3932d0ef3730..1a7e7bf77248b6f863d4a6dbc1e268b4c5ae3576 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -1017,7 +1017,7 @@ }, }, { - "context": "GitPanel && ChangesList", + "context": "GitPanel && ChangesList && !GitBranchSelector", "use_key_equivalents": true, "bindings": { "k": "menu::SelectPrevious",