diff options
| -rw-r--r-- | background_scripts/commands.coffee | 2 | ||||
| -rw-r--r-- | background_scripts/main.coffee | 10 | 
2 files changed, 7 insertions, 5 deletions
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 01eecd81..fbecc8f0 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -339,7 +339,7 @@ commandDescriptions =    createTab: ["Create new tab", { background: true, repeatLimit: 20 }]    duplicateTab: ["Duplicate current tab", { background: true, repeatLimit: 20 }] -  removeTab: ["Close current tab", { background: true, repeatLimit: +  removeTab: ["Close current tab", { background: true, passCountToFunction: true, repeatLimit:      # Require confirmation to remove more tabs than we can restore.      (if chrome.session then chrome.session.MAX_SESSION_RESULTS else 25) }]    restoreTab: ["Restore closed tab", { background: true, repeatLimit: 20 }] 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  | 
