summaryrefslogtreecommitdiff
path: root/graph/web/viewer.js
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-09-22 15:50:22 -0700
committerCliff Click <cliffc@acm.org>2026-09-22 15:50:22 -0700
commitfb80ada35ce2806c2f617a0e336d2ca4ab1d5d12 (patch)
treef27250a0efcc74354831da98d2cf764dfa7d9216 /graph/web/viewer.js
parented13d1ca215ea094b4d6beab89b90ab4c05ed396 (diff)
downloadSimple-fb80ada35ce2806c2f617a0e336d2ca4ab1d5d12.tar.gz
Simple-fb80ada35ce2806c2f617a0e336d2ca4ab1d5d12.zip
Graph cleanup
Phis stay with regions, stop sinks to bottom,
Diffstat (limited to 'graph/web/viewer.js')
-rw-r--r--graph/web/viewer.js8
1 files changed, 6 insertions, 2 deletions
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;