mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
Wrap around split focus with next and previous
This commit is contained in:
@ -247,9 +247,19 @@ extension Ghostty {
|
||||
// Determine our desired direction
|
||||
guard let directionAny = notification.userInfo?[Notification.SplitDirectionKey] else { return }
|
||||
guard let direction = directionAny as? SplitFocusDirection else { return }
|
||||
guard let next = neighbors.get(direction: direction) else { return }
|
||||
|
||||
// Find the next surface to move to. In most cases this should be
|
||||
// finding the neighbor in provided direction, and focus it. When
|
||||
// the neighbor cannot be found based on next or previous direction,
|
||||
// this would instead search for first or last leaf and focus it
|
||||
// instead, giving the wrap around effect.
|
||||
// When other directions are provided, this can be nil, and early
|
||||
// returned.
|
||||
guard let nextSurface = neighbors.get(direction: direction)?.preferredFocus(direction)
|
||||
?? node?.firstOrLast(direction)?.surface else { return }
|
||||
|
||||
Ghostty.moveFocus(
|
||||
to: next.preferredFocus(direction)
|
||||
to: nextSurface
|
||||
)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user