From 6a95e2938741de83c5f305207d4426ae4906aaa6 Mon Sep 17 00:00:00 2001 From: saberoueslati Date: Tue, 31 Mar 2026 07:56:37 +0100 Subject: [PATCH] git_panel: Fix space key being swallowed in branch picker (#52779) ## Context Fixes a regression where typing a space in the Git Panel's "Switch Branch" picker would make no response at all instead of inserting the character. The same picker in the title-bar Git Switcher was unaffected. Root cause: `PopoverMenu` links the opened menu's focus handle into the parent element's dispatch tree so that `contains_focused` returns `true` on the parent while the popover is open. `GitPanel::dispatch_context` uses `contains_focused` to decide whether to add the `ChangesList` key context, so that context is active while the branch picker is open. Because `Picker` and `Editor` have no binding for a bare `space`, dispatch fell through to the `"GitPanel && ChangesList"` binding, which maps `space` to `git::ToggleStaged`, consuming the keystroke before it could reach the text input. The fix narrows the context guard to `"GitPanel && ChangesList && !GitBranchSelector"`, so those bindings are skipped whenever the branch picker (or any other `GitBranchSelector` context) is focused inside the panel. The same change is applied to the vim keymap, which would have similarly intercepted `k`, `j`, `x`, and other letter keys typed in the picker, this behavior was observed in https://github.com/zed-industries/zed/issues/52617 and I made the same fix in https://github.com/zed-industries/zed/pull/52687 Closes #52771 and potentially https://github.com/zed-industries/zed/issues/52617 Video of the manual test of the fix below : [Screencast from 2026-03-31 00-01-54.webm](https://github.com/user-attachments/assets/76f64507-4f5a-4a8e-8582-4cdb9bec584c) ## How to Review - `assets/keymaps/default-linux.json`, `default-windows.json`, `default-macos.json`, `vim.json` : identical one-line change in each: I added `&& !GitBranchSelector` to the `"GitPanel && ChangesList"` . No Rust changes needed. ## 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 space and other keys being swallowed when typing in the Git Panel branch picker --- assets/keymaps/default-linux.json | 2 +- assets/keymaps/default-macos.json | 2 +- assets/keymaps/default-windows.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index d5643e092268470e61b54001ab57d83ec7cd9467..84b814e27a702232f5c54a6745b31f42935ca7a5 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -960,7 +960,7 @@ }, }, { - "context": "GitPanel && ChangesList", + "context": "GitPanel && ChangesList && !GitBranchSelector", "bindings": { "left": "git_panel::CollapseSelectedEntry", "right": "git_panel::ExpandSelectedEntry", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index e2073c170b375baea22f5018c2c7dba632dd9b05..1ffe011a25b74c6e7fdb30282f86b0667fc54793 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -1031,7 +1031,7 @@ }, }, { - "context": "GitPanel && ChangesList", + "context": "GitPanel && ChangesList && !GitBranchSelector", "use_key_equivalents": true, "bindings": { "up": "git_panel::PreviousEntry", diff --git a/assets/keymaps/default-windows.json b/assets/keymaps/default-windows.json index 32f827259cbcf8bab39a8bbe45a9010d7239e2a7..8ceec7e7f494c352b65a7a1f5aa1ad608eb5ff96 100644 --- a/assets/keymaps/default-windows.json +++ b/assets/keymaps/default-windows.json @@ -955,7 +955,7 @@ }, }, { - "context": "GitPanel && ChangesList", + "context": "GitPanel && ChangesList && !GitBranchSelector", "use_key_equivalents": true, "bindings": { "up": "git_panel::PreviousEntry",