Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(cli): preserve coverage for exact phrase matches (#6001)

Cindy Zhangb3c6619892c6
diff --git a/packages/cli/api/search/search.mjs b/packages/cli/api/search/search.mjs
index 810df266d8..3abdbfd8ce 100644
--- a/packages/cli/api/search/search.mjs
+++ b/packages/cli/api/search/search.mjs
@@ -274,7 +274,7 @@ export function scoreQuery(term, tokens, candidate) {
// of Table-related templates each match "table" and "contents" separately
// and accumulate a higher raw score (#5239).
if (full && full.score >= 90) {
- return {score: full.score + 100, reason: full.reason};
+ return asFull({score: full.score + 100, reason: full.reason});
}
// Multi-word natural language: score each content token, counting only
diff --git a/packages/cli/api/search/search.test.mjs b/packages/cli/api/search/search.test.mjs
index d398a4bd0e..9cd3a90736 100644
--- a/packages/cli/api/search/search.test.mjs
+++ b/packages/cli/api/search/search.test.mjs
@@ -80,6 +80,7 @@ describe('search leaf — exact keyword phrase outranks incidental token matches
// pushing it out of the results entirely at the default limit.
const r = await search('table of contents', {cwd});
expect(r.data.results[0]?.name).toBe('Outline');
+ expect(r.data.results[0]).toMatchObject({matchedTerms: 2, queryTerms: 2});
}, SLOW);
it('surfaces Outline for its own declared keyword "heading navigation", ranked first', async () => {