Consume Cmd+number shortcuts even when workspace index is out of bounds (#2033)
When pressing Cmd+N for a workspace number that doesn't exist, the event was not consumed and fell through to Ghostty's goto_tab binding, which could create a new window. Now the event is always consumed when the digit matches, preventing unintended window creation. Fixes #1970 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9a24db93a7
commit
03355ca3fc
1 changed files with 13 additions and 10 deletions
|
|
@ -9484,18 +9484,21 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
|
|||
}
|
||||
|
||||
// Numeric shortcuts for specific workspaces (9 = last workspace)
|
||||
if let manager = tabManager,
|
||||
let digit = numberedShortcutDigit(
|
||||
event: event,
|
||||
shortcut: KeyboardShortcutSettings.shortcut(for: .selectWorkspaceByNumber)
|
||||
),
|
||||
let targetIndex = WorkspaceShortcutMapper.workspaceIndex(forDigit: digit, workspaceCount: manager.tabs.count) {
|
||||
// Always consume the event when the digit matches to prevent Ghostty's
|
||||
// goto_tab fallback from creating a new window when the index is out of bounds.
|
||||
if let digit = numberedShortcutDigit(
|
||||
event: event,
|
||||
shortcut: KeyboardShortcutSettings.shortcut(for: .selectWorkspaceByNumber)
|
||||
) {
|
||||
if let manager = tabManager,
|
||||
let targetIndex = WorkspaceShortcutMapper.workspaceIndex(forDigit: digit, workspaceCount: manager.tabs.count) {
|
||||
#if DEBUG
|
||||
dlog(
|
||||
"shortcut.action name=workspaceDigit digit=\(digit) targetIndex=\(targetIndex) manager=\(debugManagerToken(manager)) \(debugShortcutRouteSnapshot(event: event))"
|
||||
)
|
||||
dlog(
|
||||
"shortcut.action name=workspaceDigit digit=\(digit) targetIndex=\(targetIndex) manager=\(debugManagerToken(manager)) \(debugShortcutRouteSnapshot(event: event))"
|
||||
)
|
||||
#endif
|
||||
manager.selectTab(at: targetIndex)
|
||||
manager.selectTab(at: targetIndex)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue