completions.ts: Add empty completion option for option deselection

This commit is contained in:
glacambre 2018-03-15 18:49:35 +01:00
parent 8f70717f18
commit 20dfaed659
No known key found for this signature in database
GPG key ID: B9625DB1767553AC

View file

@ -292,11 +292,12 @@ abstract class CompletionSourceFuse extends CompletionSource {
if (this.state != "hidden") {
let visopts = this.options.filter(o => o.state != "hidden")
let currind = visopts.findIndex(o => o.state == "focused")
if (inc < 0 && currind == -1) inc += 1
this.deselect()
this.select(
visopts[(currind + inc + visopts.length) % visopts.length],
)
// visopts.length + 1 because we want an empty completion at the end
let max = visopts.length + 1
let opt = visopts[(currind + inc + max) % max]
if (opt)
this.select(opt)
return true
} else return false
}