diff options
| author | Stephen Blott | 2014-10-26 11:10:16 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2014-10-26 11:10:16 +0000 | 
| commit | f66b14e0f13270a739843e7b2e0bc0e3f1bc1d09 (patch) | |
| tree | c1718dffc8aaf61cfec9d312514878cdc8ee583f /background_scripts | |
| parent | 1497320447dd7b0a25f1ee167d92b441894e63d3 (diff) | |
| parent | f18f3ead03640585fbd78bd9fd1acdbaaec087b1 (diff) | |
| download | vimium-f66b14e0f13270a739843e7b2e0bc0e3f1bc1d09.tar.bz2 | |
Merge branch 'fix-tab-restore' of github.com:mrmr1993/vimium into mrmr1993-fix-tab-restore
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/main.coffee | 27 | 
1 files changed, 15 insertions, 12 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index e611bf75..14ce7b0f 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -250,7 +250,8 @@ BackgroundCommands =    restoreTab: (callback) ->      # TODO: remove if-else -block when adopted into stable      if chrome.sessions -      chrome.sessions.restore(null, (restoredSession) -> callback()) +      chrome.sessions.restore(null, (restoredSession) -> +          callback() unless chrome.runtime.lastError)      else        # TODO(ilya): Should this be getLastFocused instead?        chrome.windows.getCurrent((window) -> @@ -412,16 +413,17 @@ chrome.tabs.onRemoved.addListener (tabId) ->    # If we restore pages that content scripts can't run on, they'll ignore Vimium keystrokes when they    # reappear. Pretend they never existed and adjust tab indices accordingly. Could possibly expand this into    # a blacklist in the future. -  if (/^(chrome|view-source:)[^:]*:\/\/.*/.test(openTabInfo.url)) -    for i of tabQueue[openTabInfo.windowId] -      if (tabQueue[openTabInfo.windowId][i].positionIndex > openTabInfo.positionIndex) -        tabQueue[openTabInfo.windowId][i].positionIndex-- -    return - -  if (tabQueue[openTabInfo.windowId]) -    tabQueue[openTabInfo.windowId].push(openTabInfo) -  else -    tabQueue[openTabInfo.windowId] = [openTabInfo] +  unless chrome.sessions +    if (/^(chrome|view-source:)[^:]*:\/\/.*/.test(openTabInfo.url)) +      for i of tabQueue[openTabInfo.windowId] +        if (tabQueue[openTabInfo.windowId][i].positionIndex > openTabInfo.positionIndex) +          tabQueue[openTabInfo.windowId][i].positionIndex-- +      return + +    if (tabQueue[openTabInfo.windowId]) +      tabQueue[openTabInfo.windowId].push(openTabInfo) +    else +      tabQueue[openTabInfo.windowId] = [openTabInfo]    # keep the reference around for a while to wait for the last messages from the closed tab (e.g. for updating    # scroll position) @@ -431,7 +433,8 @@ chrome.tabs.onRemoved.addListener (tabId) ->  chrome.tabs.onActiveChanged.addListener (tabId, selectInfo) -> updateActiveState(tabId) -chrome.windows.onRemoved.addListener (windowId) -> delete tabQueue[windowId] +unless chrome.sessions +  chrome.windows.onRemoved.addListener (windowId) -> delete tabQueue[windowId]  # End action functions | 
