|
|
@ -83,11 +83,27 @@ window.addEventListener("keypress", (e) => { |
|
|
|
browser.runtime.sendMessage(request) |
|
|
|
browser.runtime.sendMessage(request) |
|
|
|
.then(handleResponse) |
|
|
|
.then(handleResponse) |
|
|
|
.catch((err) => { |
|
|
|
.catch((err) => { |
|
|
|
|
|
|
|
console.error("Vim Vixen:", err); |
|
|
|
vvConsole.showError(err.message); |
|
|
|
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) => { |
|
|
|
messages.receive(window, (message) => { |
|
|
|
switch (message.type) { |
|
|
|
switch (message.type) { |
|
|
|
case 'vimvixen.command.blur': |
|
|
|
case 'vimvixen.command.blur': |
|
|
@ -100,16 +116,12 @@ messages.receive(window, (message) => { |
|
|
|
type: 'event.cmd.enter', |
|
|
|
type: 'event.cmd.enter', |
|
|
|
text: message.value |
|
|
|
text: message.value |
|
|
|
}).catch((e) => { |
|
|
|
}).catch((e) => { |
|
|
|
|
|
|
|
console.error("Vim Vixen:", err); |
|
|
|
vvConsole.showError(e.message); |
|
|
|
vvConsole.showError(e.message); |
|
|
|
}); |
|
|
|
}); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 'vimvixen.command.change': |
|
|
|
case 'vimvixen.command.change': |
|
|
|
browser.runtime.sendMessage({ |
|
|
|
doCompletion(message.value); |
|
|
|
type: 'event.cmd.suggest', |
|
|
|
|
|
|
|
text: message.value |
|
|
|
|
|
|
|
}).catch((e) => { |
|
|
|
|
|
|
|
vvConsole.showError(e.message); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
return; |
|
|
|
return; |
|
|
|