Move the cursor over the visible list, skipping separators and * disabled rows. Wraps at both ends.
(
visible: Array<{ item: ContextMenuItem; originalIdx: number }>,
from: number,
delta: 1 | -1
)
| 261 | /** Move the cursor over the visible list, skipping separators and |
| 262 | * disabled rows. Wraps at both ends. */ |
| 263 | function stepVisible( |
| 264 | visible: Array<{ item: ContextMenuItem; originalIdx: number }>, |
| 265 | from: number, |
| 266 | delta: 1 | -1 |
| 267 | ): number { |
| 268 | if (visible.length === 0) return 0 |
| 269 | let i = from |
| 270 | for (let k = 0; k < visible.length; k++) { |
| 271 | i = (i + delta + visible.length) % visible.length |
| 272 | const { item } = visible[i] |
| 273 | if (item.kind !== 'separator' && !item.disabled) return i |
| 274 | } |
| 275 | return from |
| 276 | } |
| 277 | |
| 278 | /** Render a label with the filter substring highlighted — makes it |
| 279 | * obvious WHY a row matched the current query. */ |