Refactor ZenWorkspaces to enhance tab switching logic with asynchronous handling for improved workspace management

This commit is contained in:
mr. M
2025-02-22 20:59:08 +01:00
parent cc0e18012d
commit 7819b561ad
2 changed files with 19 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
index 019b168c1aeae7e1c97a3ae58c99a48a27f54134..56ed0bffb0ec0863c18ef881acb4efcc590e4a96 100644
index 019b168c1aeae7e1c97a3ae58c99a48a27f54134..89045fd46888d2a15ccee1b35ed83692faaad364 100644
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -32,6 +32,7 @@ ChromeUtils.defineESModuleGetters(this, {
@@ -51,11 +51,13 @@ index 019b168c1aeae7e1c97a3ae58c99a48a27f54134..56ed0bffb0ec0863c18ef881acb4efcc
for (let i = 0; i < browsers.length; i++) {
let browser = browsers[i];
let browserCompare = cleanURL(
@@ -6364,6 +6374,7 @@ function switchToTabHavingURI(
continue;
}
if (requestedCompare == browserCompare) {
+ aWindow.ZenWorkspaces.switchIfNeeded(browser);
// If adoptIntoActiveWindow is set, and this is a cross-window switch,
// adopt the tab into the current window, after the active tab.
let doAdopt =
@@ -6392,7 +6402,9 @@ function switchToTabHavingURI(
}
if (!doAdopt) {
+ aWindow.ZenWorkspaces.switchIfNeeded(browser).then(() => {
aWindow.gBrowser.tabContainer.selectedIndex = i;
+ });
}
return true;

View File

@@ -2273,10 +2273,13 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
}
switchIfNeeded(browser) {
const tab = gBrowser.getTabForBrowser(browser);
const workspaceId = tab.getAttribute('zen-workspace-id');
if (!tab.hasAttribute('zen-essential') && workspaceId !== this.activeWorkspace) {
this.changeWorkspace({ uuid: workspaceId });
}
return new Promise(async(resolve) => {
const tab = gBrowser.getTabForBrowser(browser);
const workspaceId = tab.getAttribute('zen-workspace-id');
if (!tab.hasAttribute('zen-essential') && workspaceId !== this.activeWorkspace) {
await this.changeWorkspace({ uuid: workspaceId });
}
resolve();
});
}
})();