aboutsummaryrefslogtreecommitdiffstats
path: root/background_page.html
diff options
context:
space:
mode:
authorint32010-04-03 15:34:45 +0800
committerilya2010-04-10 19:28:42 -0700
commitfb2dc53ef01608b9ac8cc086e6a46072a204817c (patch)
treec830322b87de6674092a8b7b28be07b9bb20908a /background_page.html
parenteb1ae0badf65aa03b3227562f29b3178fc06d8de (diff)
downloadvimium-fb2dc53ef01608b9ac8cc086e6a46072a204817c.tar.bz2
Keep tab queue indices updated when a tab is detached
Diffstat (limited to 'background_page.html')
-rw-r--r--background_page.html15
1 files changed, 10 insertions, 5 deletions
diff --git a/background_page.html b/background_page.html
index 23739081..d461d3d8 100644
--- a/background_page.html
+++ b/background_page.html
@@ -341,6 +341,7 @@
// We should update all the tabs in the old window and the new window.
if (openTabs[tabId]) {
updatePositionsAndWindowsForAllTabsInWindow(openTabs[tabId].windowId);
+ updateTabQueueIndices(openTabs[tabId].windowId, openTabs[tabId].positionIndex);
}
updatePositionsAndWindowsForAllTabsInWindow(attachedInfo.newWindowId);
});
@@ -349,17 +350,21 @@
updatePositionsAndWindowsForAllTabsInWindow(moveInfo.windowId);
});
+ function updateTabQueueIndices(windowId, positionIndex) {
+ for (var i in tabQueue[windowId]) {
+ if (tabQueue[windowId][i].positionIndex > positionIndex) {
+ tabQueue[windowId][i].positionIndex--;
+ }
+ }
+ }
+
chrome.tabs.onRemoved.addListener(function(tabId) {
var openTabInfo = openTabs[tabId];
// If we restore chrome:// pages, 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[^:]*:\/\/.*/.test(openTabInfo.url)) {
- for (var i in tabQueue[openTabInfo.windowId]) {
- if (tabQueue[openTabInfo.windowId][i].positionIndex > openTabInfo.positionIndex) {
- tabQueue[openTabInfo.windowId][i].positionIndex--;
- }
- }
+ updateTabQueueIndices(openTabInfo.windowId, openTabInfo.positionIndex);
return;
}