fix(tui): support slash-separated fuzzy filter tokens
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed slash-separated fuzzy queries so provider/model completions remain matchable after insertion.
|
||||
- Fixed WezTerm inline Kitty image rendering so reserved row clears do not erase all but the top strip of tool image previews ([#5618](https://github.com/earendil-works/pi/issues/5618)).
|
||||
|
||||
## [0.79.1] - 2026-06-09
|
||||
|
||||
@@ -94,7 +94,7 @@ export function fuzzyMatch(query: string, text: string): FuzzyMatch {
|
||||
|
||||
/**
|
||||
* Filter and sort items by fuzzy match quality (best matches first).
|
||||
* Supports space-separated tokens: all tokens must match.
|
||||
* Supports whitespace- and slash-separated tokens: all tokens must match.
|
||||
*/
|
||||
export function fuzzyFilter<T>(items: T[], query: string, getText: (item: T) => string): T[] {
|
||||
if (!query.trim()) {
|
||||
@@ -103,7 +103,7 @@ export function fuzzyFilter<T>(items: T[], query: string, getText: (item: T) =>
|
||||
|
||||
const tokens = query
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.split(/[\s/]+/)
|
||||
.filter((t) => t.length > 0);
|
||||
|
||||
if (tokens.length === 0) {
|
||||
|
||||
@@ -102,4 +102,11 @@ describe("fuzzyFilter", () => {
|
||||
assert.ok(result.map((r) => r.name).includes("foo"));
|
||||
assert.ok(result.map((r) => r.name).includes("foobar"));
|
||||
});
|
||||
|
||||
it("matches slash-separated provider/model queries against reordered text", () => {
|
||||
const item = { id: "gpt-5.5", provider: "openai-codex" };
|
||||
const result = fuzzyFilter([item], "openai-codex/gpt-5.5", (model) => `${model.id} ${model.provider}`);
|
||||
|
||||
assert.deepStrictEqual(result, [item]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user