fix(editor): let short wrong-layout prefixes match by title (#283)
The #285 gate dropped every remapped (wrong-layout) candidate shorter than 3 chars, which broke the legitimate short prefix '/сщ' -> 'co' -> Code while '/co' still worked. Replace the blanket length filter with a match-TYPE gate: the original query and remaps >= 3 chars match fully (title/description/searchTerms); a short (1-2 char) remap is restricted to a TITLE fuzzy-match. So '/сщ' -> 'co' matches the 'Code' title again, while '/cy' -> 'сн' and '/b' -> 'и' still do not surface Footnote (they only ever leaked in via the 'сноска'/'примечание' searchTerm substrings, not the title). Adds positive tests for /сщ and /co; keeps the /cy and /b negatives. closes #283 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -45,6 +45,17 @@ describe("getSuggestionItems layout-aware matching", () => {
|
||||
expect(titles(getSuggestionItems({ query: "code" }))).toContain("Code");
|
||||
});
|
||||
|
||||
it("finds Code for a short wrong-layout prefix (/сщ -> co)", () => {
|
||||
// "сщ" RU->EN remaps to "co", which fuzzy-matches the "Code" title. Short
|
||||
// remaps are title-only, but a title match must still get through. See #283.
|
||||
expect(titles(getSuggestionItems({ query: "сщ" }))).toContain("Code");
|
||||
});
|
||||
|
||||
it("still finds Code for the plain short query (/co)", () => {
|
||||
// Sanity: the original (non-remapped) short query keeps full matching.
|
||||
expect(titles(getSuggestionItems({ query: "co" }))).toContain("Code");
|
||||
});
|
||||
|
||||
it("still matches genuine Cyrillic search terms (/сноска -> Footnote)", () => {
|
||||
expect(titles(getSuggestionItems({ query: "сноска" }))).toContain(
|
||||
"Footnote",
|
||||
|
||||
Reference in New Issue
Block a user