From 73a4fe0bb1f8a7296f0a174e84111ce021f1c14e Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Tue, 5 Sep 2017 13:44:21 +0900 Subject: do simple completion --- src/content/index.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/content') 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; -- cgit v1.2.3 From d8c9651b776296bdb5eb1a8687f633e60feafb10 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Tue, 5 Sep 2017 15:42:35 +0900 Subject: fix --- src/background/index.js | 2 -- src/content/index.js | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src/content') diff --git a/src/background/index.js b/src/background/index.js index 4aa3856..8913a83 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -99,7 +99,5 @@ browser.runtime.onMessage.addListener((request, sender) => { items: items }; }); - break; } - return Promise.resolve(); }); diff --git a/src/content/index.js b/src/content/index.js index e682a7f..fdc7e89 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -97,9 +97,9 @@ const doCompletion = (line) => { text: keyword }).then((completions) => { vvConsole.setCompletions([completions]); - }).catch((e) => { + }).catch((err) => { console.error("Vim Vixen:", err); - vvConsole.showError(e.message); + vvConsole.showError(err.message); }); } }; @@ -115,9 +115,9 @@ messages.receive(window, (message) => { browser.runtime.sendMessage({ type: 'event.cmd.enter', text: message.value - }).catch((e) => { + }).catch((err) => { console.error("Vim Vixen:", err); - vvConsole.showError(e.message); + vvConsole.showError(err.message); }); break; case 'vimvixen.command.change': -- cgit v1.2.3