Fix tab completions

This commit is contained in:
Shin'ya Ueoka 2018-05-12 09:47:21 +09:00
parent 4116d08642
commit a8ac7415f8
4 changed files with 31 additions and 25 deletions

View file

@ -16,16 +16,13 @@ const closeTabByKeywords = (keyword) => {
return browser.tabs.query({ currentWindow: true }).then((tabs) => {
let matched = tabs.filter((t) => {
return t.url.includes(keyword) || t.title.includes(keyword);
});
}).filter(t => !t.pinned);
if (matched.length === 0) {
throw new Error('No matching buffer for ' + keyword);
} else if (matched.length > 1) {
throw new Error('More than one match for ' + keyword);
}
if (matched[0].pinned) {
throw new Error('Cannot close a pinned tab (add ! to override)');
}
browser.tabs.remove(matched[0].id);
});
};