# git_ui: Fix Enter key selecting branch in commit modal branch picker \(\#58366\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/5791ebc2b0414c72a46ee3b85f6d6e1d3580ad2f)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 5791ebc2b0414c72a46ee3b85f6d6e1d3580ad2f

Requested commit: 5791ebc2b0414c72a46ee3b85f6d6e1d3580ad2f

Commit: 5791ebc2b0414c72a46ee3b85f6d6e1d3580ad2f

Tree: 2a438c9d5febfd28fd8f76f1a5058435db0f5145

Author: saberoueslati

Committer: GitHub

## Message

```
git_ui: Fix Enter key selecting branch in commit modal branch picker (#58366)

## Context

When the "Switch branch" picker is opened from the git commit modal and
the user presses Enter, a `\n` character was inserted into the input
instead of confirming the branch selection.

The `"GitCommit > Editor"` keymap context bound `enter` to
`editor::Newline`. This context matches *any* `Editor` descended from
`GitCommit` in the element tree, including the single-line search editor
inside the branch picker popover. Because a context-path binding is more
specific than the global `enter: menu::Confirm` binding, it took
precedence and the picker never received the confirm action.

The commit message editor uses `EditorMode::AutoHeight` (reported in key
context as `mode == auto_height`); the picker's search editor uses
`EditorMode::SingleLine`. Narrowing the context to `"GitCommit > Editor
&& mode == auto_height"` restricts the `editor::Newline` binding to the
commit message editor only. Single-line editors inside the same modal
now fall through to the global `enter: menu::Confirm`, which correctly
confirms the selection.

Closes #58022

## How to Review

Three identical one-line changes, one per platform keymap
(`default-linux.json`, `default-macos.json`, `default-windows.json`):

- `"GitCommit > Editor"` → `"GitCommit > Editor && mode == auto_height"`

Video of manual test after fix :

[Screencast from 2026-06-02
23-16-32.webm](https://github.com/user-attachments/assets/67652cc5-4f8d-42f4-a5a9-ade3499ee880)

## 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 Enter key inserting a newline instead of selecting a branch in
the commit modal branch picker
```

## Parents

- [c56914d8f2430ce594ff279ac448f06ed71bddea](https://git.cafe/gitcafe/zed/commit/c56914d8f2430ce594ff279ac448f06ed71bddea?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/5791ebc2b0414c72a46ee3b85f6d6e1d3580ad2f?format=markdown)
