diff options
| author | Phil Crosby | 2014-08-17 11:22:29 -0700 |
|---|---|---|
| committer | Phil Crosby | 2014-08-17 11:22:29 -0700 |
| commit | e3269bc19e73d4cd0ced8018b78490b41edef703 (patch) | |
| tree | 2d7cdcf7e16578bf90f57c1214212943d4951cc5 | |
| parent | 142b2afe59ab822550d90e7147152d2b0a44ef51 (diff) | |
| download | vimium-e3269bc19e73d4cd0ced8018b78490b41edef703.tar.bz2 | |
Code tweaks
| -rw-r--r-- | background_scripts/main.coffee | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 8078f4e6..431d9a31 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -297,22 +297,22 @@ BackgroundCommands = # Remove tabs before, after, or either side of the currently active tab removeTabsRelative = (direction) -> chrome.tabs.query {currentWindow: true}, (tabs) -> - chrome.tabs.query {currentWindow: true, active: true}, (activeTabArr) -> - activeTabIndex = activeTabArr[0].index + chrome.tabs.query {currentWindow: true, active: true}, (activeTabs) -> + activeTabIndex = activeTabs[0].index - switch direction + shouldDelete = switch direction when "before" - shouldDelete = (index) -> index < activeTabIndex + (index) -> index < activeTabIndex when "after" - shouldDelete = (index) -> index > activeTabIndex + (index) -> index > activeTabIndex when "both" - shouldDelete = (index) -> index != activeTabIndex + (index) -> index != activeTabIndex - removeTabIds = [] + toRemove = [] for tab in tabs if not tab.pinned and shouldDelete tab.index - removeTabIds.push tab.id - chrome.tabs.remove removeTabIds + toRemove.push tab.id + chrome.tabs.remove toRemove # Selects a tab before or after the currently selected tab. # - direction: "next", "previous", "first" or "last". |
