Skip to content

feat(app): add shortcut close the focused window with Cmd+W - #46

Merged
LeadcodeDev merged 1 commit into
mainfrom
fix/close-window
Aug 22, 2026
Merged

feat(app): add shortcut close the focused window with Cmd+W#46
LeadcodeDev merged 1 commit into
mainfrom
fix/close-window

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Collaborator

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 for KeyBinding
across 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, not quit

QuitMode::LastWindowClosed is already set from #39, so closing one window of several
leaves the rest alone and closing the last one quits. Window::remove_window goes through
that 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 HOME so the development build gets its own single-instance socket instead of
handing 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 --workspace green; cargo clippy --workspace --all-targets -- -D warnings;
cargo fmt --all --check.

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.
@LeadcodeDev LeadcodeDev added the bug Something isn't working label Aug 22, 2026
@LeadcodeDev LeadcodeDev self-assigned this Aug 22, 2026
@LeadcodeDev LeadcodeDev added the enhancement New feature or request label Aug 22, 2026
@LeadcodeDev LeadcodeDev changed the title fix(app): close the focused window with Cmd+W feat(app): add shortcut close the focused window with Cmd+W Aug 22, 2026
@LeadcodeDev
LeadcodeDev merged commit c04d13b into main Aug 22, 2026
3 checks passed
@LeadcodeDev
LeadcodeDev deleted the fix/close-window branch August 22, 2026 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cmd+W does not close the focused window

1 participant