|
316 | 316 | // Fire after the last load retry + parse time (VCDs are tiny, <20ms to parse). |
317 | 317 | }, cmdDelay); |
318 | 318 | _retryTimers.push(t); |
319 | | - // Auto-focus the first signal that has actual transitions so that |
320 | | - // transition_next/prev work without requiring the user to click a row. |
| 319 | + // Auto-select the first signal that has actual transitions so the toolbar |
| 320 | + // transition buttons work without requiring the user to click a row first. |
321 | 321 | // |
322 | | - // Surfer's transition_next/prev navigate on the KEYBOARD-FOCUSED signal, |
323 | | - // set via FocusItem(VisibleItemIndex). The visual index equals the value |
324 | | - // returned by id_of_name() (DisplayedItemRef) because Surfer assigns IDs |
325 | | - // sequentially in display order (scope header = 0, then signals in alpha order). |
326 | | - // We also call SetItemSelected so the user can see which signal is active. |
| 322 | + // FocusItem(VisibleItemIndex) sets Surfer's keyboard-navigation focus so |
| 323 | + // that Surfer's own keyboard shortcuts (← →) work on the right signal. |
| 324 | + // SetItemSelected gives the visual blue highlight. |
327 | 325 | // |
328 | | - // id_of_name() requires the full dot-separated scope path (e.g. "tb.req") |
| 326 | + // Toolbar transition buttons use MoveCursorToTransition with an explicit |
| 327 | + // variable index (_focusedVisibleIdx), which is kept in sync with the user's |
| 328 | + // current selection by the integration.js shim polling get_state(). |
| 329 | + // |
| 330 | + // index_of_name() requires the full dot-separated scope path (e.g. "tb.req") |
329 | 331 | // and returns undefined if the signal isn't in the display yet (scope_add_recursive |
330 | 332 | // may still be processing), so we poll with retries. |
331 | 333 | const firstVar = firstTransitioningVar(text); |
|
345 | 347 | const cw2 = el?.contentWindow; |
346 | 348 | if (!cw2) return; |
347 | 349 | try { |
348 | | - // Use index_of_name for FocusItem (VisibleItemIndex). |
349 | | - // Fall back to id_of_name if index_of_name is unavailable (older Surfer builds |
350 | | - // where DisplayedItemRef happened to equal VisibleItemIndex for flat scopes). |
| 350 | + // index_of_name → VisibleItemIndex (0-based position in display list). |
| 351 | + // Fall back to id_of_name if index_of_name is unavailable (older builds). |
351 | 352 | const visibleIdx = hasIndexFn |
352 | 353 | ? await cw2.index_of_name(firstVar.fullPath) |
353 | 354 | : await cw2.id_of_name(firstVar.fullPath); |
354 | 355 | if (visibleIdx === undefined) continue; |
355 | | - // FocusItem sets keyboard focus — required for transition_next/prev. |
| 356 | + // FocusItem sets keyboard-nav focus for Surfer's own ← → shortcuts. |
356 | 357 | surferMsg(cw2, { FocusItem: visibleIdx }); |
357 | 358 | _focusedVisibleIdx = visibleIdx; |
358 | 359 | // SetItemSelected gives the visual blue highlight. |
359 | | - // Prefer id_of_name (DisplayedItemRef) for SetItemSelected when available. |
| 360 | + // Uses DisplayedItemRef (id_of_name) rather than VisibleItemIndex. |
360 | 361 | const itemRef = hasIdFn |
361 | 362 | ? (await cw2.id_of_name(firstVar.fullPath) ?? visibleIdx) |
362 | 363 | : visibleIdx; |
|
0 commit comments