From 6b2271c0ee829774b0eda1cf31f19d7440e9f6d0 Mon Sep 17 00:00:00 2001 From: Shivam Parekh Date: Mon, 13 May 2024 18:09:05 -0400 Subject: [PATCH 1/2] Update Editor.swift changed tab append to tab insert at index after selected tab --- CodeEdit/Features/Editor/Models/Editor.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CodeEdit/Features/Editor/Models/Editor.swift b/CodeEdit/Features/Editor/Models/Editor.swift index ffc71f152..ae8267be8 100644 --- a/CodeEdit/Features/Editor/Models/Editor.swift +++ b/CodeEdit/Features/Editor/Models/Editor.swift @@ -195,7 +195,12 @@ final class Editor: ObservableObject, Identifiable { if let index { tabs.insert(item, at: index) } else { - tabs.append(item) + guard let currentTab = selectedTab, let currentIndex = tabs.firstIndex(of: currentTab) + else { + tabs.append(item) + return + } + tabs.insert(item, at: tabs.index(after: currentIndex)) } selectedTab = item if !fromHistory { From 9fd0aa40d843c7aec2d6ac2fcc47f4b8316af8d9 Mon Sep 17 00:00:00 2001 From: Shivam Parekh Date: Mon, 13 May 2024 18:25:12 -0400 Subject: [PATCH 2/2] Update Editor.swift Fixed issue where tab deleted tab next to it. --- CodeEdit/Features/Editor/Models/Editor.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CodeEdit/Features/Editor/Models/Editor.swift b/CodeEdit/Features/Editor/Models/Editor.swift index ae8267be8..626393d73 100644 --- a/CodeEdit/Features/Editor/Models/Editor.swift +++ b/CodeEdit/Features/Editor/Models/Editor.swift @@ -200,7 +200,8 @@ final class Editor: ObservableObject, Identifiable { tabs.append(item) return } - tabs.insert(item, at: tabs.index(after: currentIndex)) + let nextIndex = tabs.index(after: currentIndex) + tabs.insert(item, at: nextIndex) } selectedTab = item if !fromHistory {