(width: number)
| 72 | } |
| 73 | |
| 74 | render(width: number): string[] { |
| 75 | const lines: string[] = []; |
| 76 | |
| 77 | // If no items match filter, show message |
| 78 | if (this.filteredItems.length === 0) { |
| 79 | lines.push(this.theme.noMatch(" No matching commands")); |
| 80 | return lines; |
| 81 | } |
| 82 | |
| 83 | const primaryColumnWidth = this.getPrimaryColumnWidth(); |
| 84 | |
| 85 | // Calculate visible range with scrolling |
| 86 | const startIndex = Math.max( |
| 87 | 0, |
| 88 | Math.min(this.selectedIndex - Math.floor(this.maxVisible / 2), this.filteredItems.length - this.maxVisible), |
| 89 | ); |
| 90 | const endIndex = Math.min(startIndex + this.maxVisible, this.filteredItems.length); |
| 91 | |
| 92 | // Render visible items |
| 93 | for (let i = startIndex; i < endIndex; i++) { |
| 94 | const item = this.filteredItems[i]; |
| 95 | if (!item) continue; |
| 96 | |
| 97 | const isSelected = i === this.selectedIndex; |
| 98 | const descriptionSingleLine = item.description ? normalizeToSingleLine(item.description) : undefined; |
| 99 | lines.push(this.renderItem(item, isSelected, width, descriptionSingleLine, primaryColumnWidth)); |
| 100 | } |
| 101 | |
| 102 | // Add scroll indicators if needed |
| 103 | if (startIndex > 0 || endIndex < this.filteredItems.length) { |
| 104 | const scrollText = ` (${this.selectedIndex + 1}/${this.filteredItems.length})`; |
| 105 | // Truncate if too long for terminal |
| 106 | lines.push(this.theme.scrollInfo(truncateToWidth(scrollText, width - 2, ""))); |
| 107 | } |
| 108 | |
| 109 | return lines; |
| 110 | } |
| 111 | |
| 112 | handleInput(keyData: string): void { |
| 113 | const kb = getKeybindings(); |
nothing calls this directly
no test coverage detected