Skip to content

Split Ctrl+W: close-tab vs close-pane shortcuts#19

Draft
mvbmir wants to merge 1 commit into
mvbmir/monitor-ghostty-actionsfrom
mvbmir/close-tab-shortcut
Draft

Split Ctrl+W: close-tab vs close-pane shortcuts#19
mvbmir wants to merge 1 commit into
mvbmir/monitor-ghostty-actionsfrom
mvbmir/close-tab-shortcut

Conversation

@mvbmir
Copy link
Copy Markdown
Owner

@mvbmir mvbmir commented Apr 17, 2026

Summary

Follow-up to #18. Previously Ctrl+W closed the entire pane (including all its tabs), which is surgery most users don't want by default. This PR splits the bindings so the common case (close one tab) has the familiar shortcut and the aggressive one moves to a modifier.

  • New shortcut: close_focused_tab — default Ctrl+W. Closes the active tab in the focused pane. If that was the last tab, the pane's existing on_empty callback fires and the pane is removed (and the workspace if it was the last pane).
  • Remapped: close_focused_pane — default Ctrl+Alt+W (was Ctrl+W). Same behavior as before — closes the whole pane with all its tabs.
  • Configurable: both appear in the keybindings editor, can be remapped or cleared by the user.
  • Close-pane button tooltip already reads from the resolved shortcut config (pane_action_tooltipshortcuts.tooltip_text), so it automatically reflects whichever binding is active, including user overrides.

Base: mvbmir/monitor-ghostty-actions (the redesign PR #18). Will rebase / base-change to main after #18 merges.

Follow-ups to consider before merging

  • Search bar in the keybindings editor — 48 shortcuts and growing; a simple filter input would help a lot with finding and remapping. Not blocking this PR but would be a natural companion change.
  • Allow fully unbinding a shortcut — verify the editor supports clearing a binding entirely for users who'd rather not have a specific action mapped at all. If it doesn't, add explicit UX for it.

Notes for reviewers

  • Users with shortcuts.json overrides for close_focused_pane keep their existing binding. Users who want Ctrl+W to still close the whole pane can restore that by binding close_focused_pane to <Ctrl>w in the editor (and rebinding close_focused_tab elsewhere or clearing it).
  • Middle-click-to-close-tab is unchanged (that lives in Redesign top bar + sidebar, add settings (#5) #18, not here).

Test plan

  • cargo fmt clean
  • cargo clippy --release -- -D warnings clean
  • cargo test — all 154 unit tests pass (definition count updated 47 → 48)
  • Manual: Ctrl+W closes a single tab, pane stays when 2+ tabs present
  • Manual: Ctrl+W on a pane's last tab closes the pane
  • Manual: Ctrl+W on the workspace's last pane's last tab closes the workspace
  • Manual: Ctrl+Alt+W closes the pane regardless of tab count
  • Manual: close-pane button tooltip reads "Close pane (Ctrl+Alt+W)" by default
  • Manual: keybindings editor shows both Close Focused Tab and Close Focused Pane; both can be remapped and cleared

Previously Ctrl+W closed the whole pane. That's surgery — the common
case for most users is closing a single tab. Add a dedicated
CloseFocusedTab shortcut and move CloseFocusedPane out of the way.

- New ShortcutId / ShortcutCommand: CloseFocusedTab.
  Default accel: <Ctrl>w. Closes the active tab in the focused pane;
  when the last tab closes, the pane's on_empty callback fires and the
  pane is removed (and the workspace if that was the last pane).
- CloseFocusedPane default accel remapped from <Ctrl>w to <Ctrl><Alt>w.
  Still closes the whole pane (all its tabs).
- Added pane::close_active_tab_in_pane() — the underlying helper that
  the new shortcut dispatches to. Same code path as the close X on
  each tab and the middle-click close.
- Close pane button tooltip already renders the current keybinding via
  pane_action_tooltip / shortcuts.tooltip_text, so it automatically
  reflects the new Ctrl+Alt+W default and any user remaps — no code
  change needed there.
- definitions_cover_current_host_shortcuts test updated (47 → 48).

Users with an existing shortcuts.json keeping the old "close_focused_pane"
override will continue to see their chosen binding for that action;
they'll need to bind close_focused_tab themselves if the default Ctrl+W
is not what they want.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant