aboutsummaryrefslogtreecommitdiff
path: root/src/background/tabs.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2017-09-04 07:54:27 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2017-09-05 18:15:24 +0900
commit4341f5ab620bc9e7b1e8b02f74167fa8c77c8f90 (patch)
tree814cd7dce6590c4ce1814402c4f30873b86e4c65 /src/background/tabs.js
parent8cabd68b927fe7022efa11dee082aafe8c2d4f30 (diff)
select tab as rotations
Diffstat (limited to 'src/background/tabs.js')
-rw-r--r--src/background/tabs.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/background/tabs.js b/src/background/tabs.js
index efecdc4..be8ef02 100644
--- a/src/background/tabs.js
+++ b/src/background/tabs.js
@@ -31,7 +31,7 @@ const selectAt = (index) => {
});
};
-const selectByKeyword = (keyword) => {
+const selectByKeyword = (current, keyword) => {
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
let matched = tabs.filter((t) => {
return t.url.includes(keyword) || t.title.includes(keyword)
@@ -39,10 +39,12 @@ const selectByKeyword = (keyword) => {
if (matched.length == 0) {
throw new RangeError('No matching buffer for ' + keyword);
- } else if (matched.length >= 2) {
- throw new RangeError('More than one match for ' + keyword);
}
-
+ for (let tab of matched) {
+ if (tab.index > current.index) {
+ return browser.tabs.update(tab.id, { active: true });
+ }
+ }
return browser.tabs.update(matched[0].id, { active: true });
});
}