diff options
| author | Stephen Blott | 2016-02-21 06:50:48 +0000 |
|---|---|---|
| committer | Stephen Blott | 2016-02-21 06:50:48 +0000 |
| commit | c4af8a5fb217f50e3089f0f01d3a18d7d2155848 (patch) | |
| tree | ed40587fd985656dda607a72b49474c7e15fa8de /background_scripts/main.coffee | |
| parent | 636964735bc8e9f1b802dc392b628e5ff92d319f (diff) | |
| parent | eaafbbeeab7181ae1d3da3aa9495f98b593798f9 (diff) | |
| download | vimium-c4af8a5fb217f50e3089f0f01d3a18d7d2155848.tar.bz2 | |
Merge pull request #2006 from smblott-github/fix-removeTab
Fix `<count>removeTab`.
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 |
