Skip to content

Commit 5e9b59a

Browse files
thomasahleclaude
andcommitted
Update stale comments in WaveformViewer after transition button refactor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1dea2aa commit 5e9b59a

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

src/lib/components/WaveformViewer.svelte

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,18 @@
316316
// Fire after the last load retry + parse time (VCDs are tiny, <20ms to parse).
317317
}, cmdDelay);
318318
_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.
321321
//
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.
327325
//
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")
329331
// and returns undefined if the signal isn't in the display yet (scope_add_recursive
330332
// may still be processing), so we poll with retries.
331333
const firstVar = firstTransitioningVar(text);
@@ -345,18 +347,17 @@
345347
const cw2 = el?.contentWindow;
346348
if (!cw2) return;
347349
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).
351352
const visibleIdx = hasIndexFn
352353
? await cw2.index_of_name(firstVar.fullPath)
353354
: await cw2.id_of_name(firstVar.fullPath);
354355
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.
356357
surferMsg(cw2, { FocusItem: visibleIdx });
357358
_focusedVisibleIdx = visibleIdx;
358359
// 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.
360361
const itemRef = hasIdFn
361362
? (await cw2.id_of_name(firstVar.fullPath) ?? visibleIdx)
362363
: visibleIdx;

0 commit comments

Comments
 (0)