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/content | |
parent | 8cabd68b927fe7022efa11dee082aafe8c2d4f30 (diff) | |
parent | c507f7febf0d8827dafcc6fd543678af447c056c (diff) |
Merge branch 'buffer-completion'
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/index.js | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/content/index.js b/src/content/index.js index 8b3eb58..fdc7e89 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -83,11 +83,27 @@ window.addEventListener("keypress", (e) => { browser.runtime.sendMessage(request) .then(handleResponse) .catch((err) => { + console.error("Vim Vixen:", err); vvConsole.showError(err.message); - console.log(`Vim Vixen: ${err}`); }); }); +const doCompletion = (line) => { + if (line.startsWith('buffer ')) { + let keyword = line.replace('buffer ', ''); + + browser.runtime.sendMessage({ + type: 'event.cmd.tabs.completion', + text: keyword + }).then((completions) => { + vvConsole.setCompletions([completions]); + }).catch((err) => { + console.error("Vim Vixen:", err); + vvConsole.showError(err.message); + }); + } +}; + messages.receive(window, (message) => { switch (message.type) { case 'vimvixen.command.blur': @@ -99,17 +115,13 @@ messages.receive(window, (message) => { browser.runtime.sendMessage({ type: 'event.cmd.enter', text: message.value - }).catch((e) => { - vvConsole.showError(e.message); + }).catch((err) => { + console.error("Vim Vixen:", err); + vvConsole.showError(err.message); }); break; case 'vimvixen.command.change': - browser.runtime.sendMessage({ - type: 'event.cmd.suggest', - text: message.value - }).catch((e) => { - vvConsole.showError(e.message); - }); + doCompletion(message.value); break; default: return; |