aboutsummaryrefslogtreecommitdiff
path: root/src/content/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/index.js')
-rw-r--r--src/content/index.js26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/content/index.js b/src/content/index.js
index 8b3eb58..e682a7f 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((e) => {
+ console.error("Vim Vixen:", err);
+ vvConsole.showError(e.message);
+ });
+ }
+};
+
messages.receive(window, (message) => {
switch (message.type) {
case 'vimvixen.command.blur':
@@ -100,16 +116,12 @@ messages.receive(window, (message) => {
type: 'event.cmd.enter',
text: message.value
}).catch((e) => {
+ console.error("Vim Vixen:", err);
vvConsole.showError(e.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;