Bug 1939599: Tab groups can be restored by Ctrl+Shift+T r=dao,sthompson,sessionstore-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D233102
This commit is contained in:
Jeremy Swinarton
2025-01-08 22:33:13 +00:00
parent 82f19238e9
commit cf0ea617df
4 changed files with 132 additions and 11 deletions

View File

@@ -5977,6 +5977,10 @@ function restoreLastClosedTabOrWindowOrSession() {
undoCloseTab();
break;
}
case SessionStore.LAST_ACTION_CLOSED_TAB_GROUP: {
undoCloseTabGroup(lastActionTaken.closedId);
break;
}
case SessionStore.LAST_ACTION_CLOSED_WINDOW: {
undoCloseWindow();
break;
@@ -6051,6 +6055,38 @@ function undoCloseTab(aIndex, sourceWindowSSId) {
return tab;
}
/**
* Re-open a closed tab group.
* @param {string} tabGroupId
* The tab group's unique ID.
* @returns {MozTabbrowserTabGroup} the reopened group.
*/
function undoCloseTabGroup(tabGroupId) {
let targetWindow = window;
// wallpaper patch to prevent an unnecessary blank tab (bug 343895)
let blankTabToRemove = null;
if (
targetWindow.gBrowser.visibleTabs.length == 1 &&
targetWindow.gBrowser.selectedTab.isEmpty
) {
blankTabToRemove = targetWindow.gBrowser.selectedTab;
}
let group;
try {
group = SessionStore.undoCloseTabGroup(window, tabGroupId, targetWindow);
} catch (err) {
group = SessionStore.openSavedTabGroup(tabGroupId, targetWindow);
}
if (group && blankTabToRemove) {
targetWindow.gBrowser.removeTab(blankTabToRemove);
}
return group;
}
/**
* Re-open a closed window.
* @param aIndex