mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Improve split and tab navigation behavior
This commit is contained in:
@ -107,7 +107,7 @@ extension Ghostty {
|
||||
deinit {
|
||||
// This will force the didSet callbacks to run which free.
|
||||
self.app = nil
|
||||
|
||||
|
||||
#if os(macOS)
|
||||
NotificationCenter.default.removeObserver(self)
|
||||
#endif
|
||||
@ -773,8 +773,20 @@ extension Ghostty {
|
||||
return
|
||||
|
||||
case GHOSTTY_TARGET_SURFACE:
|
||||
guard let surface = target.target.surface else { return }
|
||||
guard let surfaceView = self.surfaceView(from: surface) else { return }
|
||||
guard let surface = target.target.surface,
|
||||
let surfaceView = self.surfaceView(from: surface),
|
||||
let window = surfaceView.window,
|
||||
let controller = window.windowController as? TerminalController,
|
||||
let surfaceTree = controller.surfaceTree else { return }
|
||||
|
||||
if !surfaceTree.isViewInSplit(surfaceView) &&
|
||||
(direction == GHOSTTY_GOTO_SPLIT_NEXT || direction == GHOSTTY_GOTO_SPLIT_PREVIOUS) {
|
||||
let tabDirection: ghostty_action_goto_tab_e = direction == GHOSTTY_GOTO_SPLIT_NEXT ?
|
||||
GHOSTTY_GOTO_TAB_NEXT : GHOSTTY_GOTO_TAB_PREVIOUS
|
||||
gotoTab(app, target: target, tab: tabDirection)
|
||||
return
|
||||
}
|
||||
|
||||
NotificationCenter.default.post(
|
||||
name: Notification.ghosttyFocusSplit,
|
||||
object: surfaceView,
|
||||
|
@ -130,6 +130,15 @@ extension Ghostty {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if the view is in a split (not a single leaf)
|
||||
func isViewInSplit(_ view: SurfaceView) -> Bool {
|
||||
if case .split = self {
|
||||
return contains(view: view)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
/// Find a surface view by UUID.
|
||||
func findUUID(uuid: UUID) -> SurfaceView? {
|
||||
switch (self) {
|
||||
|
Reference in New Issue
Block a user