Eliminate tab content flickering during tab movement on macOS

This commit is contained in:
Bryan Lee
2025-02-13 13:26:24 +08:00
parent 432beac315
commit f72fd32bf0

View File

@ -709,13 +709,21 @@ class TerminalController: BaseTerminalController {
// If our index is the same we do nothing // If our index is the same we do nothing
guard finalIndex != selectedIndex else { return } guard finalIndex != selectedIndex else { return }
// Get our parent // Get our target window
let parent = tabbedWindows[finalIndex] let targetWindow = tabbedWindows[finalIndex]
// Move our current selected window to the proper index // Begin a group of window operations to minimize visual updates
NSAnimationContext.beginGrouping()
NSAnimationContext.current.duration = 0
// Remove and re-add the window in the correct position
tabGroup.removeWindow(selectedWindow) tabGroup.removeWindow(selectedWindow)
parent.addTabbedWindow(selectedWindow, ordered: action.amount < 0 ? .below : .above) targetWindow.addTabbedWindow(selectedWindow, ordered: action.amount < 0 ? .below : .above)
selectedWindow.makeKeyAndOrderFront(nil)
// Ensure our window remains selected
selectedWindow.makeKey()
NSAnimationContext.endGrouping()
} }
@objc private func onGotoTab(notification: SwiftUI.Notification) { @objc private func onGotoTab(notification: SwiftUI.Notification) {