@@ -114,6 +114,8 @@ struct EditorTabs: View {
114
114
CGFloat ( 140 )
115
115
)
116
116
}
117
+
118
+
117
119
118
120
// Disable the rule because this function is implementing the drag gesture and its animations.
119
121
// It is fairly complicated, so ignore the function body length limitation for now.
@@ -271,6 +273,17 @@ struct EditorTabs: View {
271
273
}
272
274
}
273
275
}
276
+ private func selectNextTab( ) {
277
+ guard let currentIndex = openedTabs. firstIndex ( of: editor. selectedTab? . file. id ?? " " ) else { return }
278
+ let nextIndex = ( currentIndex + 1 ) % openedTabs. count // Wraps around to the first tab if it's the last one
279
+ editor. selectedTab = editor. tabs. first { $0. file. id == openedTabs [ nextIndex] }
280
+ }
281
+
282
+ private func selectPreviousTab( ) {
283
+ guard let currentIndex = openedTabs. firstIndex ( of: editor. selectedTab? . file. id ?? " " ) , !openedTabs. isEmpty else { return }
284
+ let previousIndex = ( currentIndex - 1 + openedTabs. count) % openedTabs. count // Wraps around to the last tab if it's the first one
285
+ editor. selectedTab = editor. tabs. first { $0. file. id == openedTabs [ previousIndex] }
286
+ }
274
287
275
288
// swiftlint:enable function_body_length cyclomatic_complexity
276
289
@@ -385,6 +398,17 @@ struct EditorTabs: View {
385
398
EditorTabBarNativeInactiveBackground ( )
386
399
}
387
400
}
401
+ // keyboard shortcuts to go to next and previous tabs
402
+ Button ( action: selectNextTab) {
403
+ EmptyView ( )
404
+ }
405
+ . hidden ( )
406
+ . keyboardShortcut ( " ] " , modifiers: [ . command, . shift] )
407
+ Button ( action: selectPreviousTab) {
408
+ EmptyView ( )
409
+ }
410
+ . hidden ( )
411
+ . keyboardShortcut ( " [ " , modifiers: [ . command, . shift] )
388
412
}
389
413
. background {
390
414
if tabBarStyle == . native {
@@ -412,6 +436,7 @@ struct EditorTabs: View {
412
436
}
413
437
}
414
438
}
439
+
415
440
}
416
441
417
442
private struct EditorTabOnDropDelegate : DropDelegate {
0 commit comments