diff options
Diffstat (limited to 'background_scripts/main.coffee')
| -rw-r--r-- | background_scripts/main.coffee | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index e0215436..295c9d25 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -214,11 +214,7 @@ BackgroundCommands = previousTab: (request) -> selectTab "previous", request firstTab: (request) -> selectTab "first", request lastTab: (request) -> selectTab "last", request - removeTab: ({count, tab}) -> - chrome.tabs.query {currentWindow: true}, (tabs) -> - activeTabIndex = tab.index - startTabIndex = Math.max 0, Math.min activeTabIndex, tabs.length - count - chrome.tabs.remove (tab.id for tab in tabs[startTabIndex...startTabIndex + count]) + removeTab: ({count, tab}) -> forCountTabs count, tab, (tab) -> chrome.tabs.remove tab.id restoreTab: mkRepeatCommand (request, callback) -> chrome.sessions.restore null, callback request togglePinTab: ({tab}) -> chrome.tabs.update tab.id, {pinned: !tab.pinned} toggleMuteTab: toggleMuteTab @@ -244,6 +240,12 @@ BackgroundCommands = count = Math.min count, tabs.length chrome.tabs.reload tab.id, {bypassCache} for tab in tabs[...count] +forCountTabs = (count, currentTab, callback) -> + chrome.tabs.query {currentWindow: true}, (tabs) -> + activeTabIndex = currentTab.index + startTabIndex = Math.max 0, Math.min activeTabIndex, tabs.length - count + callback tab for tab in tabs[startTabIndex...startTabIndex + count] + # Remove tabs before, after, or either side of the currently active tab removeTabsRelative = (direction, {tab: activeTab}) -> chrome.tabs.query {currentWindow: true}, (tabs) -> |
