Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(shared): stop single-token message search at the best hit #28930

Mergedhieu-lee(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/28930/headmerged by maria-rcks View on GitHub

Showing 2 changed files with 39 additions and 3 deletions.

x
0 of 2 viewed, 2 left
29 additions and 0 deletionspackages/shared/src/paletteSearch.test.tsModified
View file
@@ -661,6 +661,26 @@
expect(scoreMessageMatch("We trust the build", "rust")).toEqual({ quality: 0.3, offset: 4 });
expect(scoreMessageMatch("Rust and trust", "rust")).toEqual({ quality: 1, offset: 0 });
expect(scoreMessageMatch("Use the sidebar", '"sidebar"')).toEqual({ quality: 1, offset: 8 });
+ for (const [text, query, expected] of [
+ ["model mode mode", "mode", { quality: 1, offset: 6 }],
+ ["xmode model models", "mode", { quality: 0.8, offset: 6 }],
+ ["model models", "mode", { quality: 0.8, offset: 0 }],
+ ["xmode ymode", "mode", { quality: 0.3, offset: 1 }],
+ ["mode mode", "mode", { quality: 1, offset: 0 }],
+ ["fts fts", "fts", { quality: 1, offset: 0 }],
+ ["the theme", "he", null],
+ ["he theme", "he", { quality: 1, offset: 0 }],
+ ["notes", "", { quality: 1, offset: 0 }],
+ ["", "notes", null],
+ ["same same same", "same same", { quality: 1.25, offset: 0 }],
+ ["7cafe52bb8 cafe cafe", "cafe", { quality: 1, offset: 11 }],
+ ["7cafe52bb8 7cafe52bb8", "7cafe52", { quality: 1, offset: 0 }],
+ ["明天部署部署到生产环境", "部署", { quality: 1, offset: 2 }],
+ ["gannet’s gannet's", "gannet's", { quality: 1, offset: 9 }],
+ ["gannet's gannet’s", "gannet’s", { quality: 1, offset: 0 }],
+ ] as const) {
+ expect(scoreMessageMatch(text, query), `${query} in ${text}`).toEqual(expected);
+ }
// Words written together as typed rank above the same words apart, and
// the snippet starts where they are together.
const together = "Run the tests, then vp run dev to check";
@@ -736,5 +756,14 @@
expect(scoreMessageMatch("İ Enable fts and model", "fts")).toMatchObject({ offset: 9 });