Skip to content

Commit 0e3bd5d

Browse files
committed
Make use of tab.lastAccessed to determine group-selected
1 parent 88fd3e8 commit 0e3bd5d

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

chrome/content/tabutils-st.js

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,8 @@ tabutils._stackTabs = function() {
228228
if (tabs.length == 0)
229229
return;
230230

231-
if (typeof aTab == "string" || !aTab.selected && !aTab.hasAttribute("group-selected")) {
231+
if (typeof aTab == "string") {
232232
aTab = tabs[0];
233-
for (let tab of tabs) {
234-
if (tab.hasAttribute("group-selected")) {
235-
aTab = tab;
236-
break;
237-
}
238-
}
239233
}
240234

241235
let group = options.id ? Services.nsIUUIDGenerator.generateUUID().toString()
@@ -251,21 +245,23 @@ tabutils._stackTabs = function() {
251245
tab.removeAttribute("group-first");
252246
tab.removeAttribute("group-last");
253247
tab.collapsed = collapsed;
248+
249+
if (tab._lastAccessed > aTab._lastAccessed)
250+
aTab = tab;
254251
}
255252
tabutils._tabPrefObserver.updateStackColor(group, color);
256253

257-
if (!aTab.selected && tabs.indexOf(this.mCurrentTab) > -1)
258-
aTab = this.mCurrentTab;
259-
260254
aTab.collapsed = false;
261255
tabutils.setAttribute(aTab, "group-selected", true);
262256
aTab.setAttribute("group-counter", tabs.length);
263257
tabs[0].setAttribute("group-first", true);
264258
tabs[tabs.length - 1].setAttribute("group-last", true);
265259

266-
let tabcontent = document.getAnonymousElementByAttribute(aTab, "class", "tab-content");
267-
if (tabcontent)
268-
tabcontent.setAttribute("group-counter", "(" + tabs.length + ")");
260+
if (collapsed) {
261+
let tabcontent = document.getAnonymousElementByAttribute(aTab, "class", "tab-content");
262+
if (tabcontent)
263+
tabcontent.setAttribute("group-counter", "(" + tabs.length + ")");
264+
}
269265
};
270266

271267
tabutils.addEventListener(gBrowser.mTabContainer, "dragover", function(event) {
@@ -492,19 +488,6 @@ tabutils._stackTabs = function() {
492488
this.detachTab(aTab);
493489
});
494490

495-
TU_hookCode("gBrowser.showOnlyTheseTabs", "{", function() { // Ensure selected tab keeps when switching group
496-
Array.reduceRight(this.mTabs, function(self, aTab) {
497-
if (aTabs.indexOf(aTab) == -1)
498-
this.hideTab(aTab);
499-
}.bind(this), this);
500-
Array.reduce(this.mTabs, function(self, aTab) {
501-
if (aTabs.indexOf(aTab) > -1)
502-
this.showTab(aTab);
503-
}.bind(this), this);
504-
this.tabContainer.mTabstrip.ensureElementIsVisible(this.selectedTab, false);
505-
return;
506-
});
507-
508491
TU_hookCode("gBrowser.onTabHide", "}", function() {
509492
if (aTab.hasAttribute("group")) {
510493
this.updateStack(aTab.getAttribute("group"));

chrome/content/tabutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,8 @@ tabutils._tabClosingOptions = function() {
931931

932932
TU_hookCode("gBrowser.onTabClose", "}", function() {
933933
if (gBrowser._previewMode) {
934-
gBrowser._previewMode = false;
935934
gBrowser.selectedTab = gBrowser.mTabContainer._tabHistory[0];
935+
gBrowser._previewMode = false;
936936
}
937937
});
938938

0 commit comments

Comments
 (0)