@@ -644,6 +644,14 @@ impl Tab {
644
644
self . inner . lock ( ) . activate_pane_direction ( direction)
645
645
}
646
646
647
+ /// Returns an adjacent pane in the specified direction.
648
+ /// In cases where there are multiple adjacent panes in the
649
+ /// intended direction, we take the pane that has the largest
650
+ /// edge intersection.
651
+ pub fn get_pane_direction ( & self , direction : PaneDirection , ignore_zoom : bool ) -> Option < usize > {
652
+ self . inner . lock ( ) . get_pane_direction ( direction, ignore_zoom)
653
+ }
654
+
647
655
pub fn prune_dead_panes ( & self ) -> bool {
648
656
self . inner . lock ( ) . prune_dead_panes ( )
649
657
}
@@ -1410,34 +1418,42 @@ impl TabInner {
1410
1418
}
1411
1419
self . toggle_zoom ( ) ;
1412
1420
}
1413
- let panes = self . iter_panes ( ) ;
1421
+ if let Some ( panel_idx) = self . get_pane_direction ( direction, false ) {
1422
+ self . set_active_idx ( panel_idx) ;
1423
+ }
1424
+ }
1425
+
1426
+ fn get_pane_direction ( & mut self , direction : PaneDirection , ignore_zoom : bool ) -> Option < usize > {
1427
+ let panes = if ignore_zoom {
1428
+ self . iter_panes_ignoring_zoom ( )
1429
+ } else {
1430
+ self . iter_panes ( )
1431
+ } ;
1414
1432
1415
1433
let active = match panes. iter ( ) . find ( |pane| pane. is_active ) {
1416
1434
Some ( p) => p,
1417
1435
None => {
1418
1436
// No active pane somehow...
1419
- self . set_active_idx ( 0 ) ;
1420
- return ;
1437
+ return Some ( 0 ) ;
1421
1438
}
1422
1439
} ;
1423
1440
1424
1441
if matches ! ( direction, PaneDirection :: Next | PaneDirection :: Prev ) {
1425
1442
let max_pane_id = panes. iter ( ) . map ( |p| p. index ) . max ( ) . unwrap_or ( active. index ) ;
1426
1443
1427
- if direction == PaneDirection :: Next {
1428
- self . set_active_idx ( if active. index == max_pane_id {
1444
+ return Some ( if direction == PaneDirection :: Next {
1445
+ if active. index == max_pane_id {
1429
1446
0
1430
1447
} else {
1431
1448
active. index + 1
1432
- } ) ;
1449
+ }
1433
1450
} else {
1434
- self . set_active_idx ( if active. index == 0 {
1451
+ if active. index == 0 {
1435
1452
max_pane_id
1436
1453
} else {
1437
1454
active. index - 1
1438
- } ) ;
1439
- }
1440
- return ;
1455
+ }
1456
+ } ) ;
1441
1457
}
1442
1458
1443
1459
let mut best = None ;
@@ -1508,8 +1524,9 @@ impl TabInner {
1508
1524
drop ( recency) ;
1509
1525
1510
1526
if let Some ( ( _, target) ) = best. take ( ) {
1511
- self . set_active_idx ( target. index ) ;
1527
+ return Some ( target. index ) ;
1512
1528
}
1529
+ None
1513
1530
}
1514
1531
1515
1532
fn prune_dead_panes ( & mut self ) -> bool {
0 commit comments