Mitigate #917 until we get our heads around async

This commit is contained in:
Oliver Blanthorn 2018-08-17 18:38:51 +01:00
parent 263b4d3fa6
commit c51bdc87c7
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3

View file

@ -55,18 +55,21 @@ export class ExcmdCompletionSource extends Completions.CompletionSourceFuse {
} }
private async scoreOptions(exstrs: string[]) { private async scoreOptions(exstrs: string[]) {
let histpos = state.cmdHistory.map(s => s.split(" ")[0]).reverse() return exstrs
return exstrs.sort((a, b) => {
let posa = histpos.findIndex(x => x == a) // Too slow with large profiles
let posb = histpos.findIndex(x => x == b) // let histpos = state.cmdHistory.map(s => s.split(" ")[0]).reverse()
// If two ex commands have the same position, sort lexically // return exstrs.sort((a, b) => {
if (posa == posb) return a < b ? -1 : 1 // let posa = histpos.findIndex(x => x == a)
// If they aren't found in the list they get lower priority // let posb = histpos.findIndex(x => x == b)
if (posa == -1) return 1 // // If two ex commands have the same position, sort lexically
if (posb == -1) return -1 // if (posa == posb) return a < b ? -1 : 1
// Finally, sort by history position // // If they aren't found in the list they get lower priority
return posa < posb ? -1 : 1 // if (posa == -1) return 1
}) // if (posb == -1) return -1
// // Finally, sort by history position
// return posa < posb ? -1 : 1
// })
} }
select(option: ExcmdCompletionOption) { select(option: ExcmdCompletionOption) {