feat(app): add shortcut close the focused window with Cmd+W - #46
Merged
Conversation
gitr had no Close action at all, so the shortcut had nothing to trigger. The issue's sketch is an action, a menu item and a handler. That is two thirds of it. gpui builds a macOS menu item's key equivalent from `keymap.bindings_for_action`, and gitr binds no keys anywhere — the keymap is empty — so a "Close" item alone would have drawn without a shortcut and Cmd+W would have stayed dead. The binding is registered in the composition root beside the other global setup. `Window::remove_window` rather than `cx.quit()`: `QuitMode::LastWindowClosed` is already set, so closing one window of several leaves the rest alone and closing the last one quits, which is the behaviour #39 established and this must not undo. The same empty keymap means Quit, Minimize and Zoom have no shortcuts either. That is one binding each and out of scope here, named rather than smuggled in.
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.
Closes #44.
gitr had no Close action at all, so Cmd+W had nothing to trigger.
The sketch was two thirds of it
The issue proposes an action, a menu item and a handler. Adding those three would still
have left Cmd+W dead.
gpui builds a macOS menu item's key equivalent from
keymap.bindings_for_action(
gpui_macos/src/platform.rs:329). gitr binds no keys anywhere — grep forKeyBindingacross the tree returns nothing — so every menu item today draws with no shortcut, and a
"Close" item would have been the same. The binding is registered in the composition root
next to the other global setup.
That also means Quit, Minimize and Zoom have no shortcuts either. One binding each,
out of scope here, named rather than smuggled in.
remove_window, notquitQuitMode::LastWindowClosedis already set from #39, so closing one window of severalleaves the rest alone and closing the last one quits.
Window::remove_windowgoes throughthat path;
cx.quit()would take every window down and undo #39.Verified
Builds and runs: the window opens and the process stays up, checked by launching under a
scratch
HOMEso the development build gets its own single-instance socket instead ofhanding off to an installed one.
The keystroke itself is not verified. Driving it means posting synthetic key events
into a machine in use. What needs a human: Cmd+W with two windows open — one closes, the
other stays — then Cmd+W on the last one, which should quit.
cargo test --workspacegreen;cargo clippy --workspace --all-targets -- -D warnings;cargo fmt --all --check.