MCPcopy Create free account
hub / github.com/anomalyco/opencode / filteredFor

Function filteredFor

packages/app/src/components/settings-keybinds.tsx:176–207  ·  view source on GitHub ↗
(
  query: string,
  list: Map<string, KeybindMeta>,
  grouped: Map<KeybindGroup, string[]>,
  keybind: (id: string) => string,
)

Source from the content-addressed store, hash-verified

174}
175
176function filteredFor(
177 query: string,
178 list: Map<string, KeybindMeta>,
179 grouped: Map<KeybindGroup, string[]>,
180 keybind: (id: string) => string,
181) {
182 const value = query.toLowerCase().trim()
183 if (!value) return grouped
184
185 const out = new Map<KeybindGroup, string[]>()
186 for (const group of GROUPS) out.set(group, [])
187
188 const items = Array.from(list.entries()).map(([id, meta]) => ({
189 id,
190 title: meta.title,
191 group: meta.group,
192 keybind: keybind(id),
193 }))
194
195 const results = fuzzysort.go(value, items, {
196 keys: ["title", "keybind"],
197 threshold: -10000,
198 })
199
200 for (const result of results) {
201 const ids = out.get(result.obj.group)
202 if (!ids) continue
203 ids.push(result.obj.id)
204 }
205
206 return out
207}
208
209function useKeyCapture(input: {
210 active: () => string | null

Callers 1

SettingsKeybindsFunction · 0.85

Calls 5

pushMethod · 0.80
getMethod · 0.65
keybindFunction · 0.50
setMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected