From a651dbf3bf884c5f3ba47f13ed035762da8979b2 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 24 Oct 2024 19:56:52 -0700 Subject: [PATCH] macos: fix goto last tab --- .../Sources/Features/Terminal/TerminalController.swift | 10 +++++----- src/input/Binding.zig | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index a015d88d6..d06cb0d3e 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -514,14 +514,14 @@ class TerminalController: BaseTerminalController { return } } else { - // Tabs are 0-indexed here, so we subtract one from the key the user hit. - finalIndex = Int(tabIndex - 1) + // The configured value is 1-indexed. + guard tabIndex >= 1 else { return } + + // If our index is outside our boundary then we use the max + finalIndex = min(Int(tabIndex - 1), tabbedWindows.count - 1) } guard finalIndex >= 0 else { return } - if finalIndex >= tabbedWindows.count { - finalIndex = tabbedWindows.count - 1 - } let targetWindow = tabbedWindows[finalIndex] targetWindow.makeKeyAndOrderFront(nil) } diff --git a/src/input/Binding.zig b/src/input/Binding.zig index c9e90d946..64016659a 100644 --- a/src/input/Binding.zig +++ b/src/input/Binding.zig @@ -297,7 +297,8 @@ pub const Action = union(enum) { /// Go to the last tab (the one with the highest index) last_tab: void, - /// Go to the tab with the specific number, 1-indexed. + /// Go to the tab with the specific number, 1-indexed. If the tab number + /// is higher than the number of tabs, this will go to the last tab. goto_tab: usize, /// Toggle the tab overview.