( current: Panel | null, direction: 'left' | 'right', visiblePanels: Panel[] )
| 76 | |
| 77 | /** Move left (h/k) or right (l/j) through the visible panel list. */ |
| 78 | export function resolveNextPanel( |
| 79 | current: Panel | null, |
| 80 | direction: 'left' | 'right', |
| 81 | visiblePanels: Panel[] |
| 82 | ): Panel | null { |
| 83 | if (visiblePanels.length === 0) return null |
| 84 | if (!current || !visiblePanels.includes(current)) return visiblePanels[0] |
| 85 | const idx = visiblePanels.indexOf(current) |
| 86 | if (direction === 'left') { |
| 87 | return idx > 0 ? visiblePanels[idx - 1] : visiblePanels[idx] |
| 88 | } |
| 89 | return idx < visiblePanels.length - 1 ? visiblePanels[idx + 1] : visiblePanels[idx] |
| 90 | } |
| 91 | |
| 92 | // --------------------------------------------------------------------------- |
| 93 | // Vim mode detection |
no outgoing calls
no test coverage detected