From fb80ada35ce2806c2f617a0e336d2ca4ab1d5d12 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 22 Sep 2026 15:50:22 -0700 Subject: Graph cleanup Phis stay with regions, stop sinks to bottom, --- graph/web/viewer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'graph/web/viewer.js') diff --git a/graph/web/viewer.js b/graph/web/viewer.js index 63ee195e..4a88245b 100644 --- a/graph/web/viewer.js +++ b/graph/web/viewer.js @@ -87,9 +87,13 @@ async function render(index) { if (generation === frameGeneration) { renderer.show(frame.snap, frame.layout, frame.evt); if (frame.pos >= 0) { - // Stepping focuses a button; focus the source so its selection is visible. + // A newline or EOF has no visible character to highlight. Show the last + // parsed character there, rather than losing the position indicator. + let pos = Math.min(frame.pos, program.value.length); + while (pos > 0 && (!program.value[pos] || /\s/.test(program.value[pos]))) pos--; + program.setSelectionRange(pos, pos + 1); + // Focus after selecting, so the browser brings the new position into view. program.focus({preventScroll: true}); - program.setSelectionRange(frame.pos, frame.pos + 1); } } rendering = false; -- cgit v1.2.3