From 2dcdc4f21629f7637777fe120e6dffb68dc22486 Mon Sep 17 00:00:00 2001 From: Michal Matczuk Date: Thu, 5 Nov 2026 08:14:38 +0000 Subject: [PATCH] git_ui: Make JetBrains Ctrl-K focus the commit message (#66330) In the JetBrains keymap, `ctrl-k` (`cmd-k` on macOS) toggles focus on the Git Panel. If the panel is on History, the shortcut leaves you there instead of taking you to the commit message. This PR binds the shortcut to `git_panel::FocusEditor` and makes that action available from the workspace. It opens the Git Panel, switches to Changes, shows the commit editor if hidden, and focuses it. Pressing the shortcut again keeps focus on the commit message. `alt-0` / `cmd-0` still toggles focus between the Git Panel and the editor, and the existing `tab` / `shift-tab` bindings in the changes list keep their behavior. ## Testing Manually tested on Linux (Fedora 44, Wayland) with a debug build and `"base_keymap": "JetBrains"`. 1. With the Git Panel on History and the editor focused, press `ctrl-k`: the panel switches to Changes and focuses the commit message. 2. Repeat with the History list focused and with the Git Panel closed. 3. Hide the commit editor and press `ctrl-k`: it becomes visible and receives focus. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Fixed `ctrl-k` (`cmd-k` on macOS) in the JetBrains keymap to focus the commit message, including when the Git Panel is on History or closed. --------- Co-authored-by: Kirill Bulatov --- assets/keymaps/linux/jetbrains.json | 2 +- assets/keymaps/macos/jetbrains.json | 2 +- crates/git_ui/src/git_panel.rs | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/assets/keymaps/linux/jetbrains.json b/assets/keymaps/linux/jetbrains.json index 183fade8a18..29137ff76b5 100644 --- a/assets/keymaps/linux/jetbrains.json +++ b/assets/keymaps/linux/jetbrains.json @@ -123,7 +123,7 @@ "shift-f10": "task::Spawn", "ctrl-f5": "task::Rerun", "ctrl-e": "file_finder::Toggle", - "ctrl-k": "git_panel::ToggleFocus", // bug: This should also focus commit editor + "ctrl-k": "git_panel::FocusEditor", "ctrl-shift-n": "file_finder::Toggle", "ctrl-alt-n": "file_finder::Toggle", "ctrl-n": "project_symbols::Toggle", diff --git a/assets/keymaps/macos/jetbrains.json b/assets/keymaps/macos/jetbrains.json index 176663ff2b3..8b8fdb8464b 100644 --- a/assets/keymaps/macos/jetbrains.json +++ b/assets/keymaps/macos/jetbrains.json @@ -126,7 +126,7 @@ "shift-f10": "task::Spawn", "cmd-f5": "task::Rerun", "cmd-e": "file_finder::Toggle", - "cmd-k": "git_panel::ToggleFocus", // bug: This should also focus commit editor + "cmd-k": "git_panel::FocusEditor", "cmd-shift-o": "file_finder::Toggle", "cmd-shift-n": "file_finder::Toggle", "cmd-n": "project_symbols::Toggle", diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index c206a1d8a9b..346aa792bd0 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -542,6 +542,11 @@ pub fn register(workspace: &mut Workspace) { workspace.register_action(|workspace, _: &ToggleFocus, window, cx| { workspace.toggle_panel_focus::(window, cx); }); + workspace.register_action(|workspace, _: &FocusEditor, window, cx| { + if let Some(panel) = workspace.focus_panel::(window, cx) { + panel.update(cx, |panel, cx| panel.focus_editor(&FocusEditor, window, cx)); + } + }); workspace.register_action(|workspace, _: &Toggle, window, cx| { if !workspace.toggle_panel_focus::(window, cx) { workspace.close_panel::(window, cx); @@ -2626,6 +2631,10 @@ impl GitPanel { } fn focus_editor(&mut self, _: &FocusEditor, window: &mut Window, cx: &mut Context) { + self.set_active_tab(GitPanelTab::Changes, window, cx); + if self.commit_editor_collapsed { + self.toggle_commit_editor(&ToggleCommitEditor, window, cx); + } self.commit_editor.update(cx, |editor, cx| { window.focus(&editor.focus_handle(cx), cx); });