diff options
| author | ilya | 2010-04-02 15:56:35 -0700 |
|---|---|---|
| committer | ilya | 2010-04-02 15:56:35 -0700 |
| commit | 15ca22e6e2d4796ea0677e237d5d4e9ff02bd4d1 (patch) | |
| tree | 09ab5f634026371c71b3152effdc13ca56087eb6 /background_page.html | |
| parent | f8a4d242a129536acbb29c7413e0b36fd97d8a74 (diff) | |
| download | vimium-15ca22e6e2d4796ea0677e237d5d4e9ff02bd4d1.tar.bz2 | |
Add more robust support for keeping track of positions/windows when tabs are moved within or between windows.
Diffstat (limited to 'background_page.html')
| -rw-r--r-- | background_page.html | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/background_page.html b/background_page.html index c78c9c2a..0e56409f 100644 --- a/background_page.html +++ b/background_page.html @@ -314,12 +314,20 @@ }); chrome.tabs.onAttached.addListener(function(tabId, attachedInfo) { - openTabs[tabId].windowId = attachedInfo.newWindowId; - openTabs[tabId].positionIndex = attachedInfo.newPosition; + // We should update all the tabs in the old window and the new window. + if (openTabs[tabId]) { + updatePositionsAndWindowsForAllTabsInWindow(openTabs[tabId].windowId); + } + updatePositionsAndWindowsForAllTabsInWindow(attachedInfo.newWindowId); + }); + + chrome.tabs.onMoved.addListener(function(tabId, moveInfo) { + updatePositionsAndWindowsForAllTabsInWindow(moveInfo.windowId); }); chrome.tabs.onRemoved.addListener(function(tabId) { var openTabInfo = openTabs[tabId]; + if (!openTabInfo) { return; } // This tab might've been opened before the extension was installed. // If we restore the new tab page, it'll ignore Vimium keystrokes when it reappears. if (openTabInfo.url == "chrome://newtab/") { return; } @@ -363,6 +371,19 @@ } // End action functions + function updatePositionsAndWindowsForAllTabsInWindow(windowId) { + chrome.tabs.getAllInWindow(windowId, function (tabs) { + for (var i = 0; i < tabs.length; i++) { + var tab = tabs[i]; + var openTabInfo = openTabs[tab.id]; + if (openTabInfo) { + openTabInfo.positionIndex = tab.index; + openTabInfo.windowId = tab.windowId; + } + } + }); + } + function splitKeyIntoFirstAndSecond(key) { if (key.search(hasModifierRegex) == 0) return { first: key.slice(0, 5), second: key.slice(5) }; |
