git_ui: Fix branch picker stealing vim keys in Git panel#52687
Merged
ChristopherBiscardi merged 1 commit intozed-industries:mainfrom Mar 31, 2026
Merged
Conversation
5 tasks
Contributor
|
thanks! I've validated that this works as intended, and it seems well-scoped to the issue |
ChristopherBiscardi
pushed a commit
that referenced
this pull request
Mar 31, 2026
## 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 #52617 and I made the same fix in #52687 Closes #52771 and potentially #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
Contributor
|
@zed-zippy approve |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
When
vim_modeis enabled, opening the branch selector popover in the Git panel and pressingi,j,k, orxtriggered Git panel actions (FocusEditor,SelectNext,ToggleStaged, etc.) instead of reaching the picker's search field.The
"GitPanel && ChangesList"keybinding block invim.jsonmatched whenever any child of the git panel's focus handle was focused — including the branch picker popover — becauseGitPanel::dispatch_context()addsChangesListbased onfocus_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'sNotpredicate evaluates against the entire context path, so adding&& !GitBranchSelectorto 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
How to Review
assets/keymaps/vim.json: changed the"GitPanel && ChangesList"context string ,I added&& !GitBranchSelector.Self-Review Checklist
Release Notes:
i,j,k,x) when vim mode is enabled