745
}
746
747
>
function fallbackCompare<T>(itemA: T, itemB: T, query: IPreparedQuery, accessor: IItemAccessor<T>): number {
fuzzyScorer.ts
748
>
749
>
// check for label + description length and prefer shorter
750
>
const labelA = accessor.getItemLabel(itemA) || '';
751
>
const labelB = accessor.getItemLabel(itemB) || '';
752
>
753
>
const descriptionA = accessor.getItemDescription(itemA);
754
>
const descriptionB = accessor.getItemDescription(itemB);
755
>
756
>
const labelDescriptionALength = labelA.length + (descriptionA ? descriptionA.length : 0);
757
>
const labelDescriptionBLength = labelB.length + (descriptionB ? descriptionB.length : 0);
758
>
759
>
if (labelDescriptionALength !== labelDescriptionBLength) {
760
return labelDescriptionALength - labelDescriptionBLength;
761
}