aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/background/actions/operation.js2
-rw-r--r--src/background/tabs.js18
-rw-r--r--src/shared/operations.js1
-rw-r--r--src/shared/settings/default.js1
4 files changed, 20 insertions, 2 deletions
diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js
index 1e4990c..cfee868 100644
--- a/src/background/actions/operation.js
+++ b/src/background/actions/operation.js
@@ -27,6 +27,8 @@ const exec = (operation, tab) => {
return tabs.selectFirstTab();
case operations.TAB_LAST:
return tabs.selectLastTab();
+ case operations.TAB_PREV_SEL:
+ return tabs.selectPrevSelTab();
case operations.TAB_RELOAD:
return tabs.reload(tab, operation.cache);
case operations.TAB_PIN:
diff --git a/src/background/tabs.js b/src/background/tabs.js
index b34f7c2..d50d8e5 100644
--- a/src/background/tabs.js
+++ b/src/background/tabs.js
@@ -1,3 +1,13 @@
+let prevSelTab = 1;
+let currSelTab = 1;
+
+browser.tabs.onActivated.addListener((activeInfo) => {
+ return browser.tabs.query({ currentWindow: true }).then(() => {
+ prevSelTab = currSelTab;
+ currSelTab = activeInfo.tabId;
+ });
+});
+
const closeTab = (id) => {
return browser.tabs.remove(id);
};
@@ -93,6 +103,10 @@ const selectLastTab = () => {
});
};
+const selectPrevSelTab = () => {
+ return browser.tabs.update(prevSelTab, { active: true });
+};
+
const reload = (current, cache) => {
return browser.tabs.reload(
current.id,
@@ -117,6 +131,6 @@ const duplicate = (id) => {
export {
closeTab, reopenTab, selectAt, selectByKeyword, getCompletions,
- selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload,
- updateTabPinned, toggleTabPinned, duplicate
+ selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, selectPrevSelTab,
+ reload, updateTabPinned, toggleTabPinned, duplicate
};
diff --git a/src/shared/operations.js b/src/shared/operations.js
index 7334369..19466df 100644
--- a/src/shared/operations.js
+++ b/src/shared/operations.js
@@ -38,6 +38,7 @@ export default {
TAB_NEXT: 'tabs.next',
TAB_FIRST: 'tabs.first',
TAB_LAST: 'tabs.last',
+ TAB_PREV_SEL: 'tabs.prevsel',
TAB_RELOAD: 'tabs.reload',
TAB_PIN: 'tabs.pin',
TAB_UNPIN: 'tabs.unpin',
diff --git a/src/shared/settings/default.js b/src/shared/settings/default.js
index bcd7731..e81df2b 100644
--- a/src/shared/settings/default.js
+++ b/src/shared/settings/default.js
@@ -28,6 +28,7 @@ export default {
"J": { "type": "tabs.next", "count": 1 },
"g0": { "type": "tabs.first" },
"g$": { "type": "tabs.last" },
+ "<C-6>": { "type": "tabs.prevsel" },
"r": { "type": "tabs.reload", "cache": false },
"R": { "type": "tabs.reload", "cache": true },
"zp": { "type": "tabs.pin.toggle" },