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);
locations = Decoration.set(decorations); // -> DecorationSet === RangeSet<Decoration>
locations = Decoration.set(decorations, true); // -> DecorationSet === RangeSet<Decoration>
}
if (e.is(showMiniLocations)) {
// 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,
} = 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));