diff --git a/macos/Sources/Features/Primary Window/PrimaryWindowController.swift b/macos/Sources/Features/Primary Window/PrimaryWindowController.swift index eb99e0500..0d2389cd7 100644 --- a/macos/Sources/Features/Primary Window/PrimaryWindowController.swift +++ b/macos/Sources/Features/Primary Window/PrimaryWindowController.swift @@ -23,10 +23,13 @@ class PrimaryWindowController: NSWindowController, NSWindowDelegate { } func windowDidBecomeKey(_ notification: Notification) { - self.windowManager?.indexTabs() + self.windowManager?.relabelTabs() } func windowWillClose(_ notification: Notification) { - self.windowManager?.indexTabs() + // Tabs must be relabeled when a window is closed because this event + // does not fire the "windowDidBecomeKey" event on the newly focused + // window + self.windowManager?.relabelTabs() } } diff --git a/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift b/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift index 52449d24c..6cc983931 100644 --- a/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift +++ b/macos/Sources/Features/Primary Window/PrimaryWindowManager.swift @@ -180,9 +180,10 @@ class PrimaryWindowManager { } } - /// Update the accessory view of the first 9 tabs. This is called when the - /// key window changes and when a window is closed. - func indexTabs() { + /// 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. + func relabelTabs() { if let windows = self.mainWindow?.tabbedWindows { for (index, window) in windows.enumerated().prefix(9) { let string = " ⌘\(index + 1) "