(suggestions: SuggestionItem[])
| 585 | * Finds the longest common prefix among an array of suggestion items |
| 586 | */ |
| 587 | export 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 |
no test coverage detected