/** * Ranked text matching shared by the app's pickers and the daemon's history * search. A match is a tier plus the offset it was found at; lower is better on * both, so callers sort ascending and never have to invent a scale. * * Typo tolerance is opt-in via `fuzzy`. The pickers leave it off — a combobox * over a known list wants exact narrowing — while history search turns it on * because the user is recalling a title from memory. */ export interface MatchScore { tier: number; offset: number; spread?: number; } export interface MatchOptions { /** Omit or pass null to match exactly. `fuzzyPolicyForToken` picks a policy. */ fuzzy?: FuzzyPolicy | null; /** * Match characters in order within one whitespace-delimited word, so `pasbab` * finds `paseo-babysit`, but `labdes` cannot join "Label as Design". Defaults to on. */ subsequence?: boolean; } /** * How much a typo in one query token is forgiven. Short tokens get * transpositions and nothing else: at four characters a free substitution turns * "main" into "mail", "maid", and "rain", while a swap can only ever reach the * word the user meant. Null means the token is matched exactly. */ export interface FuzzyPolicy { maxEdits: number; transpositionsOnly: boolean; } export declare function fuzzyPolicyForToken(token: string): FuzzyPolicy | null; export declare function scoreMatch(query: string, text: string, options?: MatchOptions): MatchScore | null; /** Match a query against a complete displayed path, including its separators. */ export declare function scorePathMatch(query: string, path: string): MatchScore | null; export interface MatchRange { start: number; length: number; } /** * Where a score's match actually landed, so a caller can mark it. Derived from * a score rather than produced alongside one: ranking touches every candidate * and needs no ranges, while only the handful of rows that get rendered do. * * The tier decides the shape. A substring hit is one span; a subsequence hit is * the scattered characters it walked; a typo hit marks the whole word, because * the characters the user got wrong are not in the text to point at. */ export declare function matchRanges(query: string, text: string, score: MatchScore): MatchRange[]; export declare function compareMatchScores(a: MatchScore, b: MatchScore): number; export declare function tokenizeQuery(query: string): string[]; export interface TextFieldsOptions { /** * Forgive typos. The budget is per token rather than per query, because a * query mixes long words that can absorb an edit with short ones that cannot. */ typoTolerant?: boolean; /** * See `MatchOptions.subsequence`. Applied per token, so turning it off means * every token has to appear as a run of adjacent characters in some field — * `lab des` still matches "Label as Design", `labdes` no longer does. */ subsequence?: boolean; } export declare function scoreTextFields(query: string, fields: string[], options?: TextFieldsOptions): MatchScore | null; //# sourceMappingURL=text-match.d.ts.map