дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
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.
38 рядки
1.0 KiB
TypeScript
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}
|
|
/>
|
|
);
|
|
}
|