diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-05 19:37:52 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-05 19:37:52 +0900 |
commit | 2cbdc483b7ecdee0627daaf934e6010e77d68a77 (patch) | |
tree | 6f8b8667f835bfb7e778cc571d8869cb5903a08a /src/background/index.js | |
parent | 8cabd68b927fe7022efa11dee082aafe8c2d4f30 (diff) | |
parent | c507f7febf0d8827dafcc6fd543678af447c056c (diff) |
Merge branch 'buffer-completion'
Diffstat (limited to 'src/background/index.js')
-rw-r--r-- | src/background/index.js | 25 |
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(); }); |