From 7919cb266e31f719039cbaef703ed226c670fd77 Mon Sep 17 00:00:00 2001 From: Justin Su Date: Sun, 21 Jul 2024 01:33:37 -0400 Subject: [PATCH 1/4] Update comment --- macos/Sources/Features/Terminal/TerminalController.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 81b86a215..0ac42d109 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -118,7 +118,8 @@ class TerminalController: NSWindowController, NSWindowDelegate, /// Update the accessory view of each tab according to the keyboard /// shortcut that activates it (if any). This is called when the key window - /// changes and when a window is closed. + /// changes, when a window is closed, and when tabs are reordered + /// with the mouse. func relabelTabs() { // Reset this to false. It'll be set back to true later. tabListenForFrame = false From 823e07379521a799e4f260be0796857ddd4b07c7 Mon Sep 17 00:00:00 2001 From: Justin Su Date: Sat, 20 Jul 2024 23:48:30 -0400 Subject: [PATCH 2/4] Relabel all tabs and clear labels for tabs with no key equivalent --- macos/Sources/Features/Terminal/TerminalController.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 0ac42d109..85681bfc6 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -130,11 +130,18 @@ class TerminalController: NSWindowController, NSWindowDelegate, // otherwise the accessory view doesn't matter. tabListenForFrame = windows.count > 1 - for (index, window) in windows.enumerated().prefix(9) { + for (index, window) in windows.enumerated() { + guard index < 9 else { + window.keyEquivalent = "" + continue + } + let action = "goto_tab:\(index + 1)" if let equiv = ghostty.config.keyEquivalent(for: action) { window.keyEquivalent = "\(equiv)" + } else { + window.keyEquivalent = "" } } } From f57f9f2ec96eadccc37f27b2793d3491be5d4473 Mon Sep 17 00:00:00 2001 From: Justin Su Date: Sun, 21 Jul 2024 03:31:33 -0400 Subject: [PATCH 3/4] Use 1-indexed values when dealing with tabs --- macos/Sources/Features/Terminal/TerminalController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 85681bfc6..01d2f78b1 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -130,13 +130,13 @@ class TerminalController: NSWindowController, NSWindowDelegate, // otherwise the accessory view doesn't matter. tabListenForFrame = windows.count > 1 - for (index, window) in windows.enumerated() { - guard index < 9 else { + for (tab, window) in zip(1..., windows) { + guard tab <= 9 else { window.keyEquivalent = "" continue } - let action = "goto_tab:\(index + 1)" + let action = "goto_tab:\(tab)" if let equiv = ghostty.config.keyEquivalent(for: action) { window.keyEquivalent = "\(equiv)" From 5268780f00054f5108d425988fff1d10cda3be03 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 21 Jul 2024 10:09:18 -0700 Subject: [PATCH 4/4] macos: comment on clearing tab --- macos/Sources/Features/Terminal/TerminalController.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/macos/Sources/Features/Terminal/TerminalController.swift b/macos/Sources/Features/Terminal/TerminalController.swift index 01d2f78b1..3589e1a7b 100644 --- a/macos/Sources/Features/Terminal/TerminalController.swift +++ b/macos/Sources/Features/Terminal/TerminalController.swift @@ -129,15 +129,16 @@ class TerminalController: NSWindowController, NSWindowDelegate, // We only listen for frame changes if we have more than 1 window, // otherwise the accessory view doesn't matter. tabListenForFrame = windows.count > 1 - + for (tab, window) in zip(1..., windows) { + // We need to clear any windows beyond this because they have had + // a keyEquivalent set previously. guard tab <= 9 else { window.keyEquivalent = "" continue } let action = "goto_tab:\(tab)" - if let equiv = ghostty.config.keyEquivalent(for: action) { window.keyEquivalent = "\(equiv)" } else {