From 4dc692ebc8a927a5ce514d65476466fc8769f318 Mon Sep 17 00:00:00 2001 From: Alessandro Boron Date: Thu, 30 Jan 2025 12:28:35 +1100 Subject: [PATCH] Fix an issue that would create an extra tab when leaving a malicious site and only one tab is in the stack --- DuckDuckGo/TabManager.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/DuckDuckGo/TabManager.swift b/DuckDuckGo/TabManager.swift index b7d359b8c2..573e2bff95 100644 --- a/DuckDuckGo/TabManager.swift +++ b/DuckDuckGo/TabManager.swift @@ -308,8 +308,13 @@ class TabManager { } func replaceTab(at index: Int, withNewTab newTab: Tab) { - model.remove(at: index) - model.insert(tab: newTab, at: index) + // Removing a Tab automatically inserts a new one if tabs are empty. Hence add a new one only if needed + if model.tabs.count == 1 { + model.remove(at: index) + } else { + model.remove(at: index) + model.insert(tab: newTab, at: index) + } save() }