Terminal: new-tab, select-all and close-tab shortcuts - #22
Open
neo773 wants to merge 1 commit into
Open
Conversation
Ctrl+Shift+` opens a new tab (VS Code's chord), mod+A selects the buffer including scrollback, and mod+W closes the active tab through the same path as middle-click, so the last one still collapses the drawer and reaps the PTY. Three things that each fail silently if you get them wrong: Bindings have to be registered from `apply_keymap`, not `terminal::panel::init`. That function clears the keymap and `Shell::new` runs it during startup, so anything bound at app init is gone before the first frame. Shifted punctuation is written as the character it produces. `ctrl-shift-\`` parses and builds, then never matches, because the platform reports `~` with no shift modifier. Letters keep shift as a modifier; punctuation does not. zed's keymaps show the same split. macOS "Close Window" moves off ⌘W to ⌘⇧W. AppKit fires menu key equivalents in `performKeyEquivalent:`, before the key reaches any view, so a menu item on ⌘W makes every view-level ⌘W binding unreachable. zed and Safari move it for the same reason. ⌘⇧W is now the action's only binding: gpui derives the menu equivalent from the keymap, and a second ⌘W binding could hand the menu back the chord it just gave up. Select-all and close-tab are scoped to the Terminal context, which is also what gives them precedence — gpui ranks matches by context depth before registration order. On Windows and Linux they resolve to Ctrl+A and Ctrl+W and shadow readline's beginning-of-line and delete-word inside the terminal, the same trade VS Code makes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
neo773
force-pushed
the
feat/terminal-shortcuts
branch
from
August 6, 2026 21:18
8e63b6f to
6d1ce75
Compare
Contributor
Author
|
@wingleeio |
Contributor
|
@neo773 I'll review this and try to get it in tomorrow |
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.
New-tab opens the panel when it is closed and adds a tab when it is already open —
set_opencreates the first tab itself, so doing both would open two. Close-tab goes through the same path as middle-click and the tab's ×, so closing the last one still collapses the drawer and still tells the engine to reap the PTY.Three things that fail silently if you get them wrong
Bindings must be registered from
apply_keymap, notterminal::panel::init. That function clears the keymap, andShell::newruns it during startup — so anything bound at app init is gone before the first frame. No error; the shortcut simply never fires. There is a test keeping these out ofinit.Shifted punctuation is written as the character it produces.
ctrl-shift-\`` parses, builds, and then never matches: the platform reportswith no shift modifier, so a binding demanding both matches nothing. Letters are the opposite —ctrl-shift-ais right, because Shift stays a modifier. zed's keymaps show the same split (ctrl-,ctrl-?for punctuation;ctrl-shift-c,ctrl-shift-nfor letters). A test pins the chord to key~`, ctrl on, shift off.macOS "Close Window" moves off ⌘W to ⌘⇧W. AppKit fires menu key equivalents in
performKeyEquivalent:, before the key reaches any view, so a menu item holding ⌘W makes every view-level ⌘W binding unreachable. zed and Safari move it for the same reason.Consequences worth flagging
Scoping select-all and close-tab to the
Terminalcontext is also what gives them precedence: gpui ranks matches by context depth before registration order.Testing
comet-uiis 380/380 green, clippy and fmt clean. New coverage: select-all reaching into scrollback and not panicking on an empty grid; the binding table parsing, scoping, and resolvingmod-per platform.Verified in the running app that ⌘⇧W closes the window. The remaining chords are covered by unit tests but have not been through a manual pass end to end.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.