Merge pull request #516 from ueokande/close-tabs-to-the-right

Add close tabs to the right command
jh-changes
Shin'ya Ueoka 6 years ago committed by GitHub
commit 5cb6b5f76a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/background/controllers/operation.js
  2. 15
      src/background/usecases/operation.js
  3. 1
      src/settings/components/form/keymaps-form.jsx
  4. 1
      src/shared/operations.js
  5. 1
      src/shared/settings/default.js

@ -11,6 +11,8 @@ export default class OperationController {
switch (operation.type) { switch (operation.type) {
case operations.TAB_CLOSE: case operations.TAB_CLOSE:
return this.operationInteractor.close(false); return this.operationInteractor.close(false);
case operations.TAB_CLOSE_RIGHT:
return this.operationInteractor.closeRight();
case operations.TAB_CLOSE_FORCE: case operations.TAB_CLOSE_FORCE:
return this.operationInteractor.close(true); return this.operationInteractor.close(true);
case operations.TAB_REOPEN: case operations.TAB_REOPEN:

@ -21,6 +21,21 @@ export default class OperationInteractor {
return this.tabPresenter.remove([tab.id]); 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() { reopen() {
return this.tabPresenter.reopen(); return this.tabPresenter.reopen();
} }

@ -21,6 +21,7 @@ const KeyMapFields = [
['mark.jump.prefix', 'Jump to the mark'], ['mark.jump.prefix', 'Jump to the mark'],
], [ ], [
['tabs.close', 'Close a tab'], ['tabs.close', 'Close a tab'],
['tabs.close.right', 'Close tabs to the right'],
['tabs.reopen', 'Reopen closed tab'], ['tabs.reopen', 'Reopen closed tab'],
['tabs.next?{"count":1}', 'Select next Tab'], ['tabs.next?{"count":1}', 'Select next Tab'],
['tabs.prev?{"count":1}', 'Select prev Tab'], ['tabs.prev?{"count":1}', 'Select prev Tab'],

@ -45,6 +45,7 @@ export default {
// Tabs // Tabs
TAB_CLOSE: 'tabs.close', TAB_CLOSE: 'tabs.close',
TAB_CLOSE_FORCE: 'tabs.close.force', TAB_CLOSE_FORCE: 'tabs.close.force',
TAB_CLOSE_RIGHT: 'tabs.close.right',
TAB_REOPEN: 'tabs.reopen', TAB_REOPEN: 'tabs.reopen',
TAB_PREV: 'tabs.prev', TAB_PREV: 'tabs.prev',
TAB_NEXT: 'tabs.next', TAB_NEXT: 'tabs.next',

@ -24,6 +24,7 @@ export default {
"G": { "type": "scroll.bottom" }, "G": { "type": "scroll.bottom" },
"$": { "type": "scroll.end" }, "$": { "type": "scroll.end" },
"d": { "type": "tabs.close" }, "d": { "type": "tabs.close" },
"D": { "type": "tabs.close.right" },
"!d": { "type": "tabs.close.force" }, "!d": { "type": "tabs.close.force" },
"u": { "type": "tabs.reopen" }, "u": { "type": "tabs.reopen" },
"K": { "type": "tabs.prev", "count": 1 }, "K": { "type": "tabs.prev", "count": 1 },