()
| 258 | } |
| 259 | |
| 260 | export function useCommandSlashes(): Accessor<readonly CommandSlashEntry[]> { |
| 261 | const keymap = useOpencodeKeymap() |
| 262 | const entries = useKeymapSelector((keymap: OpenTuiKeymap) => |
| 263 | keymap.getCommandEntries({ |
| 264 | visibility: "reachable", |
| 265 | namespace: "palette", |
| 266 | filter: isVisiblePaletteCommand, |
| 267 | }), |
| 268 | ) |
| 269 | |
| 270 | return createMemo<CommandSlashEntry[]>(() => |
| 271 | entries().flatMap((entry) => { |
| 272 | const slashName = entry.command.slashName |
| 273 | if (typeof slashName !== "string" || !slashName) return [] |
| 274 | const slashAliases = entry.command.slashAliases |
| 275 | return { |
| 276 | display: `/${slashName}`, |
| 277 | description: |
| 278 | typeof entry.command.desc === "string" |
| 279 | ? entry.command.desc |
| 280 | : typeof entry.command.title === "string" |
| 281 | ? entry.command.title |
| 282 | : undefined, |
| 283 | aliases: Array.isArray(slashAliases) |
| 284 | ? slashAliases.filter((alias): alias is string => typeof alias === "string").map((alias) => `/${alias}`) |
| 285 | : undefined, |
| 286 | onSelect: () => keymap.dispatchCommand(entry.command.name), |
| 287 | } |
| 288 | }), |
| 289 | ) |
| 290 | } |
no test coverage detected