@@ -344,6 +344,8 @@ interface WeightedSearchField {
344344interface SearchFieldsMatch {
345345 /** Roughly 0.3 (inside a word) to 1.5 (exact title). */
346346 readonly quality : number ;
347+ /** Every counted token matched a whole word at full weight, before phrase bonuses. */
348+ readonly wholeWords : boolean ;
347349 /** Every token matched at a word start, without a typo. */
348350 readonly strong : boolean ;
349351 /** Source ranges matched in the first field, for highlighting. */
@@ -441,6 +443,7 @@ function matchSearchFields(
441443 }
442444 return {
443445 quality,
446+ wholeWords : total >= counted * WHOLE_WORD ,
444447 strong,
445448 primaryRanges : mergeRanges ( primaryRanges ) ,
446449 } ;
@@ -851,7 +854,7 @@ function matchReference(
851854 } ;
852855 return ( thread . id && matches ( thread . id ) ) ||
853856 thread . pullRequests ?. some ( ( pullRequest ) => pullRequest . references ?. some ( matches ) )
854- ? { quality : 0.6 , strong : true , primaryRanges : [ ] }
857+ ? { quality : 0.6 , wholeWords : false , strong : true , primaryRanges : [ ] }
855858 : null ;
856859}
857860
@@ -888,6 +891,7 @@ export interface ThreadSearchMatch {
888891 readonly score : number ;
889892 /** Match quality alone; see `rankSearchGroups`. */
890893 readonly quality : number ;
894+ readonly wholeWords : boolean ;
891895 /** Every token matched at a word start; see `rankSearchGroups`. */
892896 readonly strong : boolean ;
893897 /** Matched ranges in the title. */
@@ -1043,6 +1047,7 @@ export function scoreThreadSearch(
10431047 return {
10441048 score : match . quality * threadUsageBoost ( thread , now ) ,
10451049 quality : match . quality ,
1050+ wholeWords : match . wholeWords ,
10461051 // A thread's whole title never lifts its group over a command or project
10471052 // of that name: every new thread is titled "New thread" for a while.
10481053 groupQuality : Math . min ( match . quality , WHOLE_NAME - 0.01 ) ,
@@ -1146,6 +1151,7 @@ export function rankSearchGroups<
11461151 readonly pickedAt ?: number ;
11471152 readonly pickedExactly ?: boolean ;
11481153 readonly groupQuality ?: number ;
1154+ readonly wholeWords ?: boolean ;
11491155 } ,
11501156> (
11511157 groups : ReadonlyArray < { readonly group : G ; readonly items : ReadonlyArray < T > } > ,
@@ -1174,7 +1180,7 @@ export function rankSearchGroups<
11741180 const wordMatch = ( match : M ) => Math . min ( matchClass ( match . quality ) , 2 ) ;
11751181 const exactPickAt = ( match : M ) => ( match . pickedExactly ? ( match . pickedAt ?? 0 ) : 0 ) ;
11761182 // Use reorders whole words or prefixes among themselves, never a prefix above a whole word.
1177- const wholeWord = ( match : M ) => Number ( match . quality >= WHOLE_WORD ) ;
1183+ const wholeWord = ( match : M ) => Number ( match . wholeWords ?? match . quality >= WHOLE_WORD ) ;
11781184 const sorted = [ ...items ] . sort (
11791185 ( left , right ) =>
11801186 wordMatch ( right . match ) - wordMatch ( left . match ) ||
0 commit comments