From b1365e134e96adf81ed5cf9f5c5033098625a141 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 3 May 2018 17:07:24 -0300 Subject: [PATCH] Implements #461 Include commands tabcloseAllToRight and tabcloseAllToLeft closing all tabs to the left/right of the active one. No default binding included. --- src/excmds.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/excmds.ts b/src/excmds.ts index 9a046491..53b008cb 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -1269,6 +1269,36 @@ export async function tabclose(...indexes: string[]) { } } +/** Close all tabs to the right of the current one + * + */ +//#background +export async function tabcloseAllToRight() { + const tabs = await browser.tabs.query({ + pinned: false, + currentWindow: true, + }) + + const atab = await activeTab() + let ids = tabs.filter(tab => tab.index > atab.index).map(tab => tab.id) + browser.tabs.remove(ids) +} + +/** Close all tabs to the left of the current one + * + */ +//#background +export async function tabcloseAllToLeft() { + const tabs = await browser.tabs.query({ + pinned: false, + currentWindow: true, + }) + + const atab = await activeTab() + let ids = tabs.filter(tab => tab.index < atab.index).map(tab => tab.id) + browser.tabs.remove(ids) +} + /** restore most recently closed tab in this window unless the most recently closed item was a window */ //#background export async function undo() {