Skip to content

Commit

Permalink
When finding the closest loaded tab, don't first walk left and then r…
Browse files Browse the repository at this point in the history
…ight, but actually look both ways at the same time.

This closes #29.
  • Loading branch information
philikon committed Mar 27, 2010
1 parent 38c0b71 commit 7b2e717
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions chrome/content/browser.js
Expand Up @@ -456,16 +456,20 @@ var BarTap = {
}

/* Otherwise walk the tab list and see if we can find an active one */
let i;
for (i = aTab._tPos - 1; i >= 0; i--) {
if (aTabBrowser.mTabs[i].getAttribute("ontap") != "true") {
return aTabBrowser.mTabs[i];
let i = 1;
while ((aTab._tPos - i >= 0) ||
(aTab._tPos + i < aTabBrowser.mTabs.length)) {
if (aTab._tPos - i >= 0) {
if (aTabBrowser.mTabs[aTab._tPos-i].getAttribute("ontap") != "true") {
return aTabBrowser.mTabs[aTab._tPos-i];
}
}
}
for (i = aTab._tPos + 1; i < aTabBrowser.mTabs.length; i++) {
if (aTabBrowser.mTabs[i].getAttribute("ontap") != "true") {
return aTabBrowser.mTabs[i];
if (aTab._tPos + i < aTabBrowser.mTabs.length) {
if (aTabBrowser.mTabs[aTab._tPos+i].getAttribute("ontap") != "true") {
return aTabBrowser.mTabs[aTab._tPos+i];
}
}
i++;
}

/* Fallback: there isn't an active tab available, so we're going to have
Expand Down

0 comments on commit 7b2e717

Please sign in to comment.