From d34b5f532ffc9457bef94cdf4b946b408d34f8c2 Mon Sep 17 00:00:00 2001 From: agent_coder Date: Thu, 2 Jul 2026 08:16:08 +0300 Subject: [PATCH] fix(#283 review r3): drop dead remap guard + use relative test import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit F4: menu-items.layout.test.ts imports from './menu-items' (relative, no extension), matching the sibling test files (was still the aliased '@/.../menu-items.ts'). F5: remove the dead 'candidate !== originalCandidate' clause from the remapped-candidate filter — buildLayoutCandidates dedupes remaps against the original via Set, so the tail after destructuring can never equal the original; the length gate is the only real condition. Comment updated to state the dedup invariant instead. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../components/slash-menu/menu-items.layout.test.ts | 2 +- .../editor/components/slash-menu/menu-items.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/client/src/features/editor/components/slash-menu/menu-items.layout.test.ts b/apps/client/src/features/editor/components/slash-menu/menu-items.layout.test.ts index c6469ecb..2e45ed30 100644 --- a/apps/client/src/features/editor/components/slash-menu/menu-items.layout.test.ts +++ b/apps/client/src/features/editor/components/slash-menu/menu-items.layout.test.ts @@ -2,7 +2,7 @@ import { describe, it, expect } from "vitest"; import { buildLayoutCandidates, getSuggestionItems, -} from "@/features/editor/components/slash-menu/menu-items.ts"; +} from "./menu-items"; /** * `buildLayoutCandidates` maps a slash query across physical keyboard layouts diff --git a/apps/client/src/features/editor/components/slash-menu/menu-items.ts b/apps/client/src/features/editor/components/slash-menu/menu-items.ts index b6b7f025..f9aaa63f 100644 --- a/apps/client/src/features/editor/components/slash-menu/menu-items.ts +++ b/apps/client/src/features/editor/components/slash-menu/menu-items.ts @@ -889,15 +889,15 @@ export const getSuggestionItems = ({ const search = query.toLowerCase(); const candidates = buildLayoutCandidates(search); // Only the original query is allowed to match via a short substring. Remapped - // (wrong-layout) candidates must be at least REMAP_MIN_LEN chars and differ - // from the original before they can match, so a 1-2 char ASCII query does not - // spuriously substring-match unrelated Cyrillic search terms (e.g. "/cy" -> - // "сн" hitting "сноска", "/b" -> "и" hitting "примечание"). + // (wrong-layout) candidates must be at least REMAP_MIN_LEN chars before they + // can match, so a 1-2 char ASCII query does not spuriously substring-match + // unrelated Cyrillic search terms (e.g. "/cy" -> "сн" hitting "сноска", + // "/b" -> "и" hitting "примечание"). buildLayoutCandidates already dedupes + // the remaps against the original, so candidates[0] is the original query. const REMAP_MIN_LEN = 3; const [originalCandidate, ...remapped] = candidates; const remappedCandidates = remapped.filter( - (candidate) => - candidate.length >= REMAP_MIN_LEN && candidate !== originalCandidate, + (candidate) => candidate.length >= REMAP_MIN_LEN, ); const filteredGroups: SlashMenuGroupedItemsType = {}; const htmlEmbedFeatureEnabled = isHtmlEmbedFeatureEnabled();