MCPcopy Create free account
hub / github.com/effect-app/libs / renderFiles

Function renderFiles

repos/effect/packages/effect/src/unstable/cli/Prompt.ts:2270–2292  ·  view source on GitHub ↗
(
  state: FileState,
  files: ReadonlyArray<string>,
  figures: Effect.Success<typeof platformFigures>,
  options: FileOptionsReq,
  renderOptions?: RenderOptions | undefined
)

Source from the content-addressed store, hash-verified

2268})
2269
2270const filterFiles = (files: ReadonlyArray<string>, query: string) => {
2271 if (query.length === 0) {
2272 return files
2273 }
2274 const normalizedQuery = query.toLowerCase()
2275 const filtered: Array<string> = []
2276 for (let index = 0; index < files.length; index++) {
2277 if (files[index].toLowerCase().includes(normalizedQuery)) {
2278 filtered.push(files[index])
2279 }
2280 }
2281 return filtered
2282}
2283
2284const updateFileState = (
2285 state: FileState,
2286 query: string,
2287 allFiles: ReadonlyArray<string> = state.allFiles
2288): FileState => {
2289 const files = filterFiles(allFiles, query)
2290 if (files.length === 0) {
2291 return { ...state, query, allFiles, files, cursor: 0 }
2292 }
2293 const selected = state.files[state.cursor]
2294 const cursor = selected === undefined ? 0 : files.indexOf(selected)
2295 return {

Callers 2

handleFileClearFunction · 0.85
Prompt.tsFile · 0.85

Calls 6

entriesToDisplayFunction · 0.85
renderPrefixFunction · 0.85
renderFileNameFunction · 0.85
pushMethod · 0.80
joinMethod · 0.80
annotateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…