mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
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 <mail4score@gmail.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -542,6 +542,11 @@ pub fn register(workspace: &mut Workspace) {
|
||||
workspace.register_action(|workspace, _: &ToggleFocus, window, cx| {
|
||||
workspace.toggle_panel_focus::<GitPanel>(window, cx);
|
||||
});
|
||||
workspace.register_action(|workspace, _: &FocusEditor, window, cx| {
|
||||
if let Some(panel) = workspace.focus_panel::<GitPanel>(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::<GitPanel>(window, cx) {
|
||||
workspace.close_panel::<GitPanel>(window, cx);
|
||||
@@ -2626,6 +2631,10 @@ impl GitPanel {
|
||||
}
|
||||
|
||||
fn focus_editor(&mut self, _: &FocusEditor, window: &mut Window, cx: &mut Context<Self>) {
|
||||
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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user