@@ -32,15 +32,9 @@ export class StackNavigationAction {
3232 callback : ( workspace ) => {
3333 const currentRoot = workspace ?. getCursor ( ) ?. getSourceBlock ( ) ?. getRootBlock ( ) ;
3434 if ( ! currentRoot ) return false ;
35- const rootList = workspace . getTopBlocks ( ) ;
36-
37- const index = rootList . indexOf ( currentRoot ) ;
38- let newIndex ;
39- do {
40- newIndex = ( index - 1 + rootList . length ) % rootList . length ;
41- } while ( ! rootList [ newIndex ] . canBeFocused ( ) ) ;
42-
43- getFocusManager ( ) . focusNode ( rootList [ newIndex ] ) ;
35+ const prevRoot = workspace . getNavigator ( ) . getPreviousSibling ( currentRoot ) ;
36+ if ( ! prevRoot ) return false ;
37+ getFocusManager ( ) . focusNode ( prevRoot ) ;
4438 return true ;
4539 } ,
4640 keyCodes : [ SHORTCUT_PREV_STACK ] ,
@@ -52,15 +46,9 @@ export class StackNavigationAction {
5246 callback : ( workspace ) => {
5347 const currentRoot = workspace ?. getCursor ( ) ?. getSourceBlock ( ) ?. getRootBlock ( ) ;
5448 if ( ! currentRoot ) return false ;
55- const rootList = workspace . getTopBlocks ( ) ;
56-
57- const index = rootList . indexOf ( currentRoot ) ;
58- let newIndex ;
59- do {
60- newIndex = ( index + 1 ) % rootList . length ;
61- } while ( ! rootList [ newIndex ] . canBeFocused ( ) ) ;
62-
63- getFocusManager ( ) . focusNode ( rootList [ newIndex ] ) ;
49+ const nextRoot = workspace . getNavigator ( ) . getNextSibling ( currentRoot ) ;
50+ if ( ! nextRoot ) return false ;
51+ getFocusManager ( ) . focusNode ( nextRoot ) ;
6452 return true ;
6553 } ,
6654 keyCodes : [ SHORTCUT_NEXT_STACK ] ,
0 commit comments