Sorting must work with pinned tabs as well
This commit is contained in:
parent
da65760bae
commit
4b92b775b4
1 changed files with 11 additions and 6 deletions
17
index.js
17
index.js
|
@ -124,22 +124,27 @@ let ContainerService =
|
|||
for (let window of windows) {
|
||||
let tabs = tabsUtils.getTabs(window);
|
||||
|
||||
// Let's collect UCIs for each tab of this window.
|
||||
let pos = 0;
|
||||
|
||||
// Let's collect UCIs/tabs for this window.
|
||||
let map = new Map;
|
||||
for (let tab of tabs) {
|
||||
let xulTab = viewFor(tab);
|
||||
let userContextId = parseInt(xulTab.getAttribute('usercontextid') || 0, 10);
|
||||
if (tabsUtils.isPinned(tab)) {
|
||||
// pinned tabs must be consider as taken positions.
|
||||
++pos;
|
||||
continue;
|
||||
}
|
||||
|
||||
let userContextId = parseInt(tab.getAttribute('usercontextid') || 0, 10);
|
||||
if (!map.has(userContextId)) {
|
||||
map.set(userContextId, []);
|
||||
}
|
||||
map.get(userContextId).push(xulTab);
|
||||
map.get(userContextId).push(tab);
|
||||
}
|
||||
|
||||
// Let's sort the map.
|
||||
let sortMap = new Map([...map.entries()].sort((a, b) => a[0] > b[0]));
|
||||
|
||||
let pos = 0;
|
||||
|
||||
// Let's move tabs.
|
||||
for (let [userContextId, tabs] of sortMap) {
|
||||
for (let tab of tabs) {
|
||||
|
|
Loading…
Add table
Reference in a new issue