aboutsummaryrefslogtreecommitdiff
path: root/src/background/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/background/index.js')
-rw-r--r--src/background/index.js25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/background/index.js b/src/background/index.js
index 15c8ab0..8913a83 100644
--- a/src/background/index.js
+++ b/src/background/index.js
@@ -55,9 +55,9 @@ const normalizeUrl = (string) => {
}
}
-const cmdBuffer = (arg) => {
+const cmdBuffer = (sender, arg) => {
if (isNaN(arg)) {
- return tabs.selectByKeyword(arg);
+ return tabs.selectByKeyword(sender.tab, arg);
} else {
let index = parseInt(arg, 10) - 1;
return tabs.selectAt(index);
@@ -73,7 +73,7 @@ const cmdEnterHandle = (request, sender) => {
return browser.tabs.create({ url: normalizeUrl(words[1]) });
case 'b':
case 'buffer':
- return cmdBuffer(words[1]);
+ return cmdBuffer(sender, words[1]);
}
throw new Error(words[0] + ' command is not defined');
};
@@ -84,9 +84,20 @@ browser.runtime.onMessage.addListener((request, sender) => {
return keyPressHandle(request, sender);
case 'event.cmd.enter':
return cmdEnterHandle(request, sender);
- case 'event.cmd.suggest':
- // TODO make suggestion and return
- break;
+ case 'event.cmd.tabs.completion':
+ return tabs.getCompletions(request.text).then((tabs) => {
+ let items = tabs.map((tab) => {
+ return {
+ caption: tab.title,
+ content: tab.title,
+ url: tab.url,
+ icon: tab.favIconUrl
+ }
+ });
+ return {
+ name: "Buffers",
+ items: items
+ };
+ });
}
- return Promise.resolve();
});