macos: rename indexTabs() to relabelTabs()

This is a better name because the tab label may not necessarily be an
index (if a user binds some non-numeric key, for instance).
This commit is contained in:
Gregory Anders
2023-09-27 22:27:48 -05:00
committed by Mitchell Hashimoto
parent 59ba6fac2b
commit 8f75e83958
2 changed files with 9 additions and 5 deletions

View File

@ -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()
}
}

View File

@ -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) "