From aded178ab7db3ec852c33e08836e410ae4f8c739 Mon Sep 17 00:00:00 2001 From: Matthew Kaney Date: Mon, 3 Jul 2023 03:55:49 -0400 Subject: [PATCH] Pass mininotation locations into highlight state --- packages/react/src/components/CodeMirror6.jsx | 2 +- website/src/repl/Repl.jsx | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/react/src/components/CodeMirror6.jsx b/packages/react/src/components/CodeMirror6.jsx index e695eeed..f4ce3a07 100644 --- a/packages/react/src/components/CodeMirror6.jsx +++ b/packages/react/src/components/CodeMirror6.jsx @@ -85,7 +85,7 @@ const miniLocations = StateField.define({ } }) .filter(Boolean); - locations = Decoration.set(decorations); // -> DecorationSet === RangeSet + locations = Decoration.set(decorations, true); // -> DecorationSet === RangeSet } if (e.is(showMiniLocations)) { // this is called every frame to show the locations that are currently active diff --git a/website/src/repl/Repl.jsx b/website/src/repl/Repl.jsx index 8629a9ac..fdbfa7db 100644 --- a/website/src/repl/Repl.jsx +++ b/website/src/repl/Repl.jsx @@ -126,6 +126,13 @@ export function Repl({ embedded = false }) { isLineWrappingEnabled, } = useSettings(); + const [miniLocations, setMiniLocations] = useState([]); + useEffect(() => { + if (view) { + updateMiniLocations(view, miniLocations); + } + }, [view, miniLocations]); + const { code, setCode, scheduler, evaluate, activateCode, isDirty, activeCode, pattern, started, stop, error } = useStrudel({ initialCode: '// LOADING...', @@ -138,9 +145,7 @@ export function Repl({ embedded = false }) { cleanupDraw(); }, afterEval: ({ code, meta }) => { - console.log('miniLocations', meta.miniLocations, view); - // TODO: find a way to get hold of the codemirror view - // then call updateMiniLocations + setMiniLocations(meta.miniLocations); setPending(false); setLatestCode(code); window.location.hash = '#' + encodeURIComponent(btoa(code));