aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/background/actions/operation.js4
-rw-r--r--src/background/tabs.js29
-rw-r--r--src/settings/components/form/keymaps-form.jsx2
-rw-r--r--src/shared/operations.js2
-rw-r--r--src/shared/settings/default.js6
-rw-r--r--src/shared/settings/storage.js4
6 files changed, 40 insertions, 7 deletions
diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js
index 1e4990c..1188ea2 100644
--- a/src/background/actions/operation.js
+++ b/src/background/actions/operation.js
@@ -17,6 +17,8 @@ const exec = (operation, tab) => {
switch (operation.type) {
case operations.TAB_CLOSE:
return tabs.closeTab(tab.id);
+ case operations.TAB_CLOSE_FORCE:
+ return tabs.closeTabForce(tab.id);
case operations.TAB_REOPEN:
return tabs.reopenTab();
case operations.TAB_PREV:
@@ -27,6 +29,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..e939870 100644
--- a/src/background/tabs.js
+++ b/src/background/tabs.js
@@ -1,4 +1,22 @@
+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.get(id).then((tab) => {
+ if (!tab.pinned) {
+ return browser.tabs.remove(id);
+ }
+ });
+};
+
+const closeTabForce = (id) => {
return browser.tabs.remove(id);
};
@@ -93,6 +111,10 @@ const selectLastTab = () => {
});
};
+const selectPrevSelTab = () => {
+ return browser.tabs.update(prevSelTab, { active: true });
+};
+
const reload = (current, cache) => {
return browser.tabs.reload(
current.id,
@@ -116,7 +138,8 @@ const duplicate = (id) => {
};
export {
- closeTab, reopenTab, selectAt, selectByKeyword, getCompletions,
- selectPrevTab, selectNextTab, selectFirstTab, selectLastTab, reload,
- updateTabPinned, toggleTabPinned, duplicate
+ closeTab, closeTabForce, reopenTab, selectAt, selectByKeyword,
+ getCompletions, selectPrevTab, selectNextTab, selectFirstTab,
+ selectLastTab, selectPrevSelTab, reload, updateTabPinned,
+ toggleTabPinned, duplicate
};
diff --git a/src/settings/components/form/keymaps-form.jsx b/src/settings/components/form/keymaps-form.jsx
index e25107c..0e4a223 100644
--- a/src/settings/components/form/keymaps-form.jsx
+++ b/src/settings/components/form/keymaps-form.jsx
@@ -26,7 +26,7 @@ const KeyMapFields = [
['tabs.reload?{"cache":false}', 'Reload current tab'],
['tabs.reload?{"cache":true}', 'Reload with no caches'],
['tabs.pin.toggle', 'Toggle pinned state'],
- ['tabs.duplicate', 'Dupplicate a tab'],
+ ['tabs.duplicate', 'Duplicate a tab'],
], [
['follow.start?{"newTab":false}', 'Follow a link'],
['follow.start?{"newTab":true}', 'Follow a link in new tab'],
diff --git a/src/shared/operations.js b/src/shared/operations.js
index ff833a2..008e9eb 100644
--- a/src/shared/operations.js
+++ b/src/shared/operations.js
@@ -36,11 +36,13 @@ export default {
// Tabs
TAB_CLOSE: 'tabs.close',
+ TAB_CLOSE_FORCE: 'tabs.close.force',
TAB_REOPEN: 'tabs.reopen',
TAB_PREV: 'tabs.prev',
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 4ad81c4..3c4dcac 100644
--- a/src/shared/settings/default.js
+++ b/src/shared/settings/default.js
@@ -23,11 +23,13 @@ export default {
"G": { "type": "scroll.bottom" },
"$": { "type": "scroll.end" },
"d": { "type": "tabs.close" },
+ "!d": { "type": "tabs.close.force" },
"u": { "type": "tabs.reopen" },
"K": { "type": "tabs.prev", "count": 1 },
"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" },
@@ -61,9 +63,9 @@ export default {
"duckduckgo": "https://duckduckgo.com/?q={}",
"twitter": "https://twitter.com/search?q={}",
"wikipedia": "https://en.wikipedia.org/w/index.php?search={}"
- },
- "properties": {
}
+ },
+ "properties": {
}
}`,
};
diff --git a/src/shared/settings/storage.js b/src/shared/settings/storage.js
index 1edb441..25ebfcd 100644
--- a/src/shared/settings/storage.js
+++ b/src/shared/settings/storage.js
@@ -18,7 +18,9 @@ const loadValue = () => {
} else if (settings.source === 'form') {
value = settingsValues.valueFromForm(settings.form);
}
- return value;
+ return Object.assign({},
+ settingsValues.valueFromJson(DefaultSettings.json),
+ value);
});
};