Keep previous selected tab
This commit is contained in:
parent
50cc126e08
commit
92a1e170e1
1 changed files with 25 additions and 9 deletions
|
@ -1,4 +1,3 @@
|
||||||
// var prevSelTab = null;
|
|
||||||
var prevSelTab = 0;
|
var prevSelTab = 0;
|
||||||
|
|
||||||
const closeTab = (id) => {
|
const closeTab = (id) => {
|
||||||
|
@ -61,6 +60,10 @@ const getCompletions = (keyword) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectPrevTab = (current, count) => {
|
const selectPrevTab = (current, count) => {
|
||||||
|
browser.tabs.query({ currentWindow: true, active: true }).then((tabs) => {
|
||||||
|
prevSelTab = tabs[0].id;
|
||||||
|
});
|
||||||
|
|
||||||
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
||||||
if (tabs.length < 2) {
|
if (tabs.length < 2) {
|
||||||
return;
|
return;
|
||||||
|
@ -72,6 +75,10 @@ const selectPrevTab = (current, count) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectNextTab = (current, count) => {
|
const selectNextTab = (current, count) => {
|
||||||
|
browser.tabs.query({ currentWindow: true, active: true }).then((tabs) => {
|
||||||
|
prevSelTab = tabs[0].id;
|
||||||
|
});
|
||||||
|
|
||||||
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
||||||
if (tabs.length < 2) {
|
if (tabs.length < 2) {
|
||||||
return;
|
return;
|
||||||
|
@ -83,6 +90,10 @@ const selectNextTab = (current, count) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectFirstTab = () => {
|
const selectFirstTab = () => {
|
||||||
|
browser.tabs.query({ currentWindow: true, active: true }).then((tabs) => {
|
||||||
|
prevSelTab = tabs[0].id;
|
||||||
|
});
|
||||||
|
|
||||||
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
||||||
let id = tabs[0].id;
|
let id = tabs[0].id;
|
||||||
return browser.tabs.update(id, { active: true });
|
return browser.tabs.update(id, { active: true });
|
||||||
|
@ -90,6 +101,10 @@ const selectFirstTab = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectLastTab = () => {
|
const selectLastTab = () => {
|
||||||
|
browser.tabs.query({ currentWindow: true, active: true }).then((tabs) => {
|
||||||
|
prevSelTab = tabs[0].id;
|
||||||
|
});
|
||||||
|
|
||||||
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
||||||
let id = tabs[tabs.length - 1].id;
|
let id = tabs[tabs.length - 1].id;
|
||||||
return browser.tabs.update(id, { active: true });
|
return browser.tabs.update(id, { active: true });
|
||||||
|
@ -97,14 +112,15 @@ const selectLastTab = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectPrevSelTab = () => {
|
const selectPrevSelTab = () => {
|
||||||
if (prevSelTab != null) {
|
var tmpPrevSelTab = null;
|
||||||
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
browser.tabs.query({ currentWindow: true, active: true }).then((tabs) => {
|
||||||
let id = tabs[prevSelTab].id;
|
tmpPrevSelTab = tabs[0].id;
|
||||||
return browser.tabs.update(id, { active: true });
|
});
|
||||||
});
|
|
||||||
} else {
|
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
|
||||||
// some error message
|
browser.tabs.update(prevSelTab, { active: true });
|
||||||
}
|
prevSelTab = tmpPrevSelTab;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const reload = (current, cache) => {
|
const reload = (current, cache) => {
|
||||||
|
|
Reference in a new issue