From 6b2271c0ee829774b0eda1cf31f19d7440e9f6d0 Mon Sep 17 00:00:00 2001 From: Shivam Parekh Date: Mon, 13 May 2024 18:09:05 -0400 Subject: [PATCH 1/3] 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/3] 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 { From 4056ed77f858639472d0bf3e369e6b8e7b692385 Mon Sep 17 00:00:00 2001 From: Shivam Parekh Date: Wed, 15 May 2024 20:59:31 -0400 Subject: [PATCH 3/3] Update Editor.swift Fixed issue where closing a file on the side window caused an error. --- CodeEdit/Features/Editor/Models/Editor.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CodeEdit/Features/Editor/Models/Editor.swift b/CodeEdit/Features/Editor/Models/Editor.swift index 626393d73..439e08a9e 100644 --- a/CodeEdit/Features/Editor/Models/Editor.swift +++ b/CodeEdit/Features/Editor/Models/Editor.swift @@ -195,13 +195,11 @@ final class Editor: ObservableObject, Identifiable { if let index { tabs.insert(item, at: index) } else { - guard let currentTab = selectedTab, let currentIndex = tabs.firstIndex(of: currentTab) - else { + if let selectedTab, let currentIndex = tabs.firstIndex(of: selectedTab) { + tabs.insert(item, at: tabs.index(after: currentIndex)) + } else { tabs.append(item) - return } - let nextIndex = tabs.index(after: currentIndex) - tabs.insert(item, at: nextIndex) } selectedTab = item if !fromHistory {