MCPcopy Create free account
hub / github.com/codeaashu/claude-code / findLongestCommonPrefix

Function findLongestCommonPrefix

src/hooks/fileSuggestions.ts:587–598  ·  view source on GitHub ↗
(suggestions: SuggestionItem[])

Source from the content-addressed store, hash-verified

585 * Finds the longest common prefix among an array of suggestion items
586 */
587export function findLongestCommonPrefix(suggestions: SuggestionItem[]): string {
588 if (suggestions.length === 0) return ''
589
590 const strings = suggestions.map(item => item.displayText)
591 let prefix = strings[0]!
592 for (let i = 1; i < strings.length; i++) {
593 const currentString = strings[i]!
594 prefix = findCommonPrefix(prefix, currentString)
595 if (prefix === '') return ''
596 }
597 return prefix
598}
599
600/**
601 * Creates a file suggestion item

Callers 1

useTypeaheadFunction · 0.85

Calls 1

findCommonPrefixFunction · 0.85

Tested by

no test coverage detected