tweak: prioritize fuzzysort results that start with user input (#5571)
This commit is contained in:
parent
337a7e9646
commit
7abc2a947e
1 changed files with 7 additions and 0 deletions
|
|
@ -364,6 +364,13 @@ export function Autocomplete(props: {
|
||||||
const result = fuzzysort.go(currentFilter, mixed, {
|
const result = fuzzysort.go(currentFilter, mixed, {
|
||||||
keys: [(obj) => obj.display.trimEnd(), "description", (obj) => obj.aliases?.join(" ") ?? ""],
|
keys: [(obj) => obj.display.trimEnd(), "description", (obj) => obj.aliases?.join(" ") ?? ""],
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
scoreFn: (objResults) => {
|
||||||
|
const displayResult = objResults[0]
|
||||||
|
if (displayResult && displayResult.target.startsWith(store.visible + currentFilter)) {
|
||||||
|
return objResults.score * 2
|
||||||
|
}
|
||||||
|
return objResults.score
|
||||||
|
},
|
||||||
})
|
})
|
||||||
return result.map((arr) => arr.obj)
|
return result.map((arr) => arr.obj)
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue