Get buffers on "tabclose" or "tabmove"

Firefox doing what it does on Escape in input
fields fires both the input and keydown listeners
leading to a race condition. Rudimentally protect
ourselves by checking completions directly since
it is always modified sequentially.
This commit is contained in:
Koushien 2017-11-15 13:41:04 -08:00 committed by Colin Caine
parent a389d6dde3
commit f3a4ca0abb

View file

@ -65,17 +65,21 @@ clInput.addEventListener("keydown", function (keyevent) {
clInput.addEventListener("input", async () => {
// TODO: Handle this in parser
if (!clInput.value.startsWith("buffer ")) {
if (clInput.value.startsWith("buffer") ||
clInput.value.startsWith("tabclose") || clInput.value.startsWith("tabmove")) {
if (completionsrc === undefined && completions.innerHTML !== "") changecompletions("buffers")
else {
completionsrc = await completionsrc.filter(clInput.value.split(/\s+/)[1])
completions.innerHTML = ""
completions.appendChild(completionsrc.activate())
sendExstr("showcmdline")
}
}
else if (completionsrc) {
completionsrc = undefined
completions.innerHTML = ""
sendExstr("showcmdline")
}
else if (completionsrc === undefined) sendExstr("buffers")
else if (completionsrc) {
completionsrc = await completionsrc.filter(clInput.value.slice(7))
completions.innerHTML = ""
completions.appendChild(completionsrc.activate())
}
sendExstr("showcmdline")
})
let cmdline_history_position = 0