From 95dd753a2f152a04dacd4d232dca5742bc67436f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Larra=C3=B1aga?= Date: Fri, 11 Oct 2024 19:18:46 -0700 Subject: [PATCH] Fixes an issue where "Close Tabs to the Right" would also close the tab the action was perfomed on. --- .../Editor/TabBar/Views/EditorTabBarContextMenu.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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) } }