aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/background/controllers/operation.js2
-rw-r--r--src/background/usecases/operation.js15
-rw-r--r--src/settings/components/form/keymaps-form.jsx1
-rw-r--r--src/shared/operations.js1
-rw-r--r--src/shared/settings/default.js1
5 files changed, 20 insertions, 0 deletions
diff --git a/src/background/controllers/operation.js b/src/background/controllers/operation.js
index aea85fc..646f50e 100644
--- a/src/background/controllers/operation.js
+++ b/src/background/controllers/operation.js
@@ -11,6 +11,8 @@ export default class OperationController {
switch (operation.type) {
case operations.TAB_CLOSE:
return this.operationInteractor.close(false);
+ case operations.TAB_CLOSE_RIGHT:
+ return this.operationInteractor.closeRight();
case operations.TAB_CLOSE_FORCE:
return this.operationInteractor.close(true);
case operations.TAB_REOPEN:
diff --git a/src/background/usecases/operation.js b/src/background/usecases/operation.js
index bf905be..dd24e75 100644
--- a/src/background/usecases/operation.js
+++ b/src/background/usecases/operation.js
@@ -21,6 +21,21 @@ export default class OperationInteractor {
return this.tabPresenter.remove([tab.id]);
}
+ async closeRight() {
+ let tabs = await this.tabPresenter.getAll();
+ tabs.sort((t1, t2) => t1.index - t2.index);
+ let index = tabs.findIndex(t => t.active);
+ if (index < 0) {
+ return;
+ }
+ for (let i = index + 1; i < tabs.length; ++i) {
+ let tab = tabs[i];
+ if (!tab.pinned) {
+ this.tabPresenter.remove(tab.id);
+ }
+ }
+ }
+
reopen() {
return this.tabPresenter.reopen();
}
diff --git a/src/settings/components/form/keymaps-form.jsx b/src/settings/components/form/keymaps-form.jsx
index eaa8336..ca51c96 100644
--- a/src/settings/components/form/keymaps-form.jsx
+++ b/src/settings/components/form/keymaps-form.jsx
@@ -21,6 +21,7 @@ const KeyMapFields = [
['mark.jump.prefix', 'Jump to the mark'],
], [
['tabs.close', 'Close a tab'],
+ ['tabs.close.right', 'Close tabs to the right'],
['tabs.reopen', 'Reopen closed tab'],
['tabs.next?{"count":1}', 'Select next Tab'],
['tabs.prev?{"count":1}', 'Select prev Tab'],
diff --git a/src/shared/operations.js b/src/shared/operations.js
index 026f97c..8674f4d 100644
--- a/src/shared/operations.js
+++ b/src/shared/operations.js
@@ -45,6 +45,7 @@ export default {
// Tabs
TAB_CLOSE: 'tabs.close',
TAB_CLOSE_FORCE: 'tabs.close.force',
+ TAB_CLOSE_RIGHT: 'tabs.close.right',
TAB_REOPEN: 'tabs.reopen',
TAB_PREV: 'tabs.prev',
TAB_NEXT: 'tabs.next',
diff --git a/src/shared/settings/default.js b/src/shared/settings/default.js
index 5b0950e..6523a74 100644
--- a/src/shared/settings/default.js
+++ b/src/shared/settings/default.js
@@ -24,6 +24,7 @@ export default {
"G": { "type": "scroll.bottom" },
"$": { "type": "scroll.end" },
"d": { "type": "tabs.close" },
+ "D": { "type": "tabs.close.right" },
"!d": { "type": "tabs.close.force" },
"u": { "type": "tabs.reopen" },
"K": { "type": "tabs.prev", "count": 1 },