fix(#283 review r3): drop dead remap guard + use relative test import

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) <noreply@anthropic.com>
This commit is contained in:
agent_coder
2026-07-02 08:16:08 +03:00
parent 0f4b03d89f
commit d34b5f532f
2 changed files with 7 additions and 7 deletions
@@ -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
@@ -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();