From eff7cfc5fec572523f609dd6e49d5e066acc07d2 Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Thu, 8 May 2025 14:40:05 +0200 Subject: [PATCH] fix: Fixed the window always closing with last tab, b=(no-bug), c=workspaces --- .../tabbrowser/content/tabbrowser-js.patch | 4 ++-- src/zen/workspaces/ZenWorkspaces.mjs | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/browser/components/tabbrowser/content/tabbrowser-js.patch b/src/browser/components/tabbrowser/content/tabbrowser-js.patch index ed375949f..3d4fe521a 100644 --- a/src/browser/components/tabbrowser/content/tabbrowser-js.patch +++ b/src/browser/components/tabbrowser/content/tabbrowser-js.patch @@ -1,5 +1,5 @@ diff --git a/browser/components/tabbrowser/content/tabbrowser.js b/browser/components/tabbrowser/content/tabbrowser.js -index 6dece2b9d0462d90a28e75350ce983d87816ef73..4042f332a9d991c31a1725a0f2b4fffebc0d11d8 100644 +index 6dece2b9d0462d90a28e75350ce983d87816ef73..fdcfd020326b45eb23cbe74d0ce53a06c17cde8a 100644 --- a/browser/components/tabbrowser/content/tabbrowser.js +++ b/browser/components/tabbrowser/content/tabbrowser.js @@ -415,11 +415,45 @@ @@ -461,7 +461,7 @@ index 6dece2b9d0462d90a28e75350ce983d87816ef73..4042f332a9d991c31a1725a0f2b4fffe } + if (ZenWorkspaces.workspaceEnabled) { -+ let newTab = ZenWorkspaces.handleTabBeforeClose(aTab); ++ let newTab = ZenWorkspaces.handleTabBeforeClose(aTab, closeWindowWithLastTab); + if (newTab) { + this.selectedTab = newTab; + } diff --git a/src/zen/workspaces/ZenWorkspaces.mjs b/src/zen/workspaces/ZenWorkspaces.mjs index b142fca00..6cb5fdec5 100644 --- a/src/zen/workspaces/ZenWorkspaces.mjs +++ b/src/zen/workspaces/ZenWorkspaces.mjs @@ -801,6 +801,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { if (this._initialTab) { if (this._initialTab._shouldRemove && this._initialTab._veryPossiblyEmpty) { + this._removedByStartupPage = true; gBrowser.removeTab(this._initialTab, { skipSessionStore: true, animate: false, @@ -818,6 +819,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { setTimeout(() => { const tabs = gBrowser.tabs.filter((tab) => !tab.collapsed && !tab.hasAttribute('zen-empty-tab')); gBrowser.selectedTab = tabs[this._tabToSelect]; + this._removedByStartupPage = true; gBrowser.removeTab(this._tabToRemoveForEmpty, { skipSessionStore: true, animate: false, @@ -827,6 +829,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { } else { this.selectEmptyTab(); showed = true; + this._removedByStartupPage = true; gBrowser.removeTab(this._tabToRemoveForEmpty, { skipSessionStore: true, animate: false, @@ -842,6 +845,9 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { } handleInitialTab(tab, isEmpty) { + if (gZenUIManager.testingEnabled) { + return; + } // note: We cant access `gZenVerticalTabsManager._canReplaceNewTab` this early if (isEmpty && Services.prefs.getBoolPref('zen.urlbar.replace-newtab', true)) { this._tabToRemoveForEmpty = tab; @@ -877,7 +883,6 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { ) { // Remove any tabs where their workspace doesn't exist anymore gBrowser.removeTab(tab, { - animate: false, skipSessionStore: true, closeWindowWithLastTab: false, }); @@ -885,7 +890,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { } } - handleTabBeforeClose(tab) { + handleTabBeforeClose(tab, closeWindowWithLastTab = false) { if (!this.workspaceEnabled || this.__contextIsDelete || this._removedByStartupPage) { return null; } @@ -897,8 +902,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature { let tabs = gBrowser.visibleTabs; let tabsPinned = tabs.filter((t) => !this.shouldOpenNewTabIfLastUnpinnedTabIsClosed || !t.pinned); - - const shouldCloseWindow = this.shouldCloseWindow(); + const shouldCloseWindow = this.shouldCloseWindow() && closeWindowWithLastTab; if (tabs.length === 1 && tabs[0] === tab) { if (shouldCloseWindow) { // We've already called beforeunload on all the relevant tabs if we get here,