import { isMacLike } from "../../common/util.ts"; import { FilterList } from "./filter.tsx"; import { CompletionContext, CompletionResult, TerminalIcon } from "../deps.ts"; import { AppCommand } from "../hooks/command.ts"; import { FilterOption } from "../../common/types.ts"; export function CommandPalette({ commands, recentCommands, onTrigger, vimMode, darkMode, completer, }: { commands: Map; recentCommands: Map; vimMode: boolean; darkMode: boolean; completer: (context: CompletionContext) => Promise; onTrigger: (command: AppCommand | undefined) => void; }) { const options: FilterOption[] = []; const isMac = isMacLike(); for (const [name, def] of commands.entries()) { options.push({ name: name, hint: isMac && def.command.mac ? def.command.mac : def.command.key, orderId: recentCommands.has(name) ? -recentCommands.get(name)!.getTime() : 0, }); } return ( { if (opt) { onTrigger(commands.get(opt.name)); } else { onTrigger(undefined); } }} /> ); }