Файли
openidea/src/ui/SearchHistoryMenu.tsx
T
l0ng-ai c61264cdf9 fix(search): keep recent find and replace values readable (#5244)
The editor Find bar and the Find and Replace in Files dialog now share one history menu. The menu can grow up to 200 px wider than its field, within the window, and the text uses the space previously reserved for icons. The heading stays visible as the list scrolls. Multi-line entries show a line-break marker and restore the original text when selected.
2026-11-23 09:13:05 +08:00

38 рядки
1.0 KiB
TypeScript

import { Menu, type MenuItem } from "./Menu";
import type { PopupAnchor } from "./Popup";
import { searchHistory } from "@/platform/search";
interface SearchHistoryMenuProps {
kind: "find" | "replace" | null;
anchor: PopupAnchor;
onSelect: (value: string) => void;
onClose: () => void;
}
export function SearchHistoryMenu({ kind, anchor, onSelect, onClose }: SearchHistoryMenuProps) {
if (kind === null) return null;
const replace = kind === "replace";
const entries = searchHistory(kind);
const items: MenuItem[] = entries.length
? entries.map((value) => ({
label: value.replace(/\r\n?|\n/g, " ⏎ "),
hint: value,
verbatim: true,
run: () => onSelect(value),
}))
: [{ label: replace ? "No recent replacements" : "No recent searches", disabled: true }];
return (
<Menu
open
anchor={anchor}
title={replace ? "Recent Replacements" : "Recent Searches"}
items={items}
iconColumn={false}
maxWidthOverAnchor={200}
onClose={onClose}
/>
);
}