Pass mininotation locations into highlight state

This commit is contained in:
Matthew Kaney 2023-07-03 03:55:49 -04:00
parent 0b5d905120
commit aded178ab7
2 changed files with 9 additions and 4 deletions

View file

@ -85,7 +85,7 @@ const miniLocations = StateField.define({
} }
}) })
.filter(Boolean); .filter(Boolean);
locations = Decoration.set(decorations); // -> DecorationSet === RangeSet<Decoration> locations = Decoration.set(decorations, true); // -> DecorationSet === RangeSet<Decoration>
} }
if (e.is(showMiniLocations)) { if (e.is(showMiniLocations)) {
// this is called every frame to show the locations that are currently active // this is called every frame to show the locations that are currently active

View file

@ -126,6 +126,13 @@ export function Repl({ embedded = false }) {
isLineWrappingEnabled, isLineWrappingEnabled,
} = useSettings(); } = 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 } = const { code, setCode, scheduler, evaluate, activateCode, isDirty, activeCode, pattern, started, stop, error } =
useStrudel({ useStrudel({
initialCode: '// LOADING...', initialCode: '// LOADING...',
@ -138,9 +145,7 @@ export function Repl({ embedded = false }) {
cleanupDraw(); cleanupDraw();
}, },
afterEval: ({ code, meta }) => { afterEval: ({ code, meta }) => {
console.log('miniLocations', meta.miniLocations, view); setMiniLocations(meta.miniLocations);
// TODO: find a way to get hold of the codemirror view
// then call updateMiniLocations
setPending(false); setPending(false);
setLatestCode(code); setLatestCode(code);
window.location.hash = '#' + encodeURIComponent(btoa(code)); window.location.hash = '#' + encodeURIComponent(btoa(code));