Skip to content

git_panel: Fix space key being swallowed in branch picker#52779

Merged
ChristopherBiscardi merged 1 commit intozed-industries:mainfrom
saberoueslati:fix-space-in-git-panel-branch-picker
Mar 31, 2026
Merged

git_panel: Fix space key being swallowed in branch picker#52779
ChristopherBiscardi merged 1 commit intozed-industries:mainfrom
saberoueslati:fix-space-in-git-panel-branch-picker

Conversation

@saberoueslati
Copy link
Copy Markdown
Contributor

@saberoueslati saberoueslati commented Mar 30, 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

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

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • 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

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 30, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, Anthony-Eid and nathansobo and removed request for a team March 30, 2026 23:08
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Mar 30, 2026
@zed-industries-bot
Copy link
Copy Markdown
Contributor

Messages
📖

This PR includes links to the following GitHub Issues: #52617
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against 035d00e

@ChristopherBiscardi
Copy link
Copy Markdown
Contributor

Thanks again! Validated the change and spaces can once again be typed. Although, spaces are not used to match against existing branch names with -, which is not the responsibility of this PR to fix.

@ChristopherBiscardi ChristopherBiscardi merged commit 6a95e29 into zed-industries:main Mar 31, 2026
42 checks passed
@zed-zippy zed-zippy bot added the PR state:needs review Used to label PRs that are in need of a post-merge approval label Apr 6, 2026
@ChristopherBiscardi
Copy link
Copy Markdown
Contributor

@zed-zippy approve

@MrSubidubi MrSubidubi removed the PR state:needs review Used to label PRs that are in need of a post-merge approval label Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't write spaces in the branch picker of the Git Panel

5 participants