diff options
Diffstat (limited to 'background_scripts/main.coffee')
| -rw-r--r-- | background_scripts/main.coffee | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 3498cf76..3eb8ef76 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -286,10 +286,12 @@ BackgroundCommands = previousTab: (count) -> selectTab "previous", count firstTab: (count) -> selectTab "first", count lastTab: (count) -> selectTab "last", count - removeTab: (callback) -> - chrome.tabs.getSelected(null, (tab) -> - chrome.tabs.remove(tab.id) - selectionChangedHandlers.push(callback)) + removeTab: (count) -> + chrome.tabs.query {currentWindow: true}, (tabs) -> + chrome.tabs.query {currentWindow: true, active: true}, (activeTabs) -> + activeTabIndex = activeTabs[0].index + startTabIndex = Math.max 0, Math.min activeTabIndex, tabs.length - count + chrome.tabs.remove (tab.id for tab in tabs[startTabIndex...startTabIndex + count]) restoreTab: (callback) -> chrome.sessions.restore null, -> callback() unless chrome.runtime.lastError |
