Add delay before a title change to avoid flicker on macOS

This commit is contained in:
Pranav Mangal
2024-12-11 23:10:03 +05:30
parent 9f75d93a55
commit 146b1f2a1b
2 changed files with 18 additions and 3 deletions

View File

@@ -53,6 +53,10 @@ class BaseTerminalController: NSWindowController,
/// Fullscreen state management.
private(set) var fullscreenStyle: FullscreenStyle?
var titleChangeDelay: TimeInterval = 0.075
private var titleChangeTimer: Timer?
/// Event monitor (see individual events for why)
private var eventMonitor: Any? = nil
@@ -260,9 +264,12 @@ class BaseTerminalController: NSWindowController,
func titleDidChange(to: String) {
guard let window else { return }
// Set the main window title
window.title = to
titleChangeTimer?.invalidate()
// Set the main window title after a small delay to prevent flicker
titleChangeTimer = Timer.scheduledTimer(withTimeInterval: titleChangeDelay, repeats: false) { _ in
window.title = to
}
}
func pwdDidChange(to: URL?) {