From 3fc5bb31d03b8bc4685eb838523466a55198c64d Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Tue, 4 Jul 2023 18:22:22 +0200 Subject: [PATCH] fix: do not recreate haps mapping on update --- packages/react/src/components/CodeMirror6.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/react/src/components/CodeMirror6.jsx b/packages/react/src/components/CodeMirror6.jsx index 00daf7d0..e1f55014 100644 --- a/packages/react/src/components/CodeMirror6.jsx +++ b/packages/react/src/components/CodeMirror6.jsx @@ -98,18 +98,17 @@ const visibleMiniLocations = StateField.define({ // this is called every frame to show the locations that are currently active // we can NOT create new marks because the context.locations haven't changed since eval time // this is why we need to find a way to update the existing decorations, showing the ones that have an active range - const haps = new Map(); for (let hap of e.value.haps) { for (let { start, end } of hap.context.locations) { let id = `${start}:${end}`; - if (!haps.has(id) || haps.get(id).whole.begin.lt(hap.whole.begin)) { - haps.set(id, hap); + if (!visible.haps.has(id) || visible.haps.get(id).whole.begin.lt(hap.whole.begin)) { + visible.haps.set(id, hap); } } } - visible = { atTime: e.value.atTime, haps }; + visible = { atTime: e.value.atTime, haps: visible.haps }; } }