diff --git a/CodeEdit/Features/Editor/TabBar/Views/EditorTabBarContextMenu.swift b/CodeEdit/Features/Editor/TabBar/Views/EditorTabBarContextMenu.swift index 7393f4fff7..78d96637af 100644 --- a/CodeEdit/Features/Editor/TabBar/Views/EditorTabBarContextMenu.swift +++ b/CodeEdit/Features/Editor/TabBar/Views/EditorTabBarContextMenu.swift @@ -53,10 +53,11 @@ struct EditorTabBarContextMenu: ViewModifier { } } } + Button("Close Tabs to the Right") { withAnimation { - if let index = tabs.tabs.firstIndex(where: { $0.file == item }) { - tabs.tabs[index...].forEach { + if let index = tabs.tabs.firstIndex(where: { $0.file == item }), index + 1 < tabs.tabs.count { + tabs.tabs[(index + 1)...].forEach { tabs.closeTab(file: $0.file) } }