From 009a108c715b02c8d62528b0bf3311280bb8d139 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Fri, 5 May 2023 09:35:15 +0100 Subject: [PATCH] Wrap setCursorHighlights in setTimeout (#12951) GitOrigin-RevId: 204bf073bc2f4a014d9498c6a802fe38e52b22c5 --- .../js/features/source-editor/hooks/use-codemirror-scope.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts b/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts index c17493a237..2ab87219b4 100644 --- a/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts +++ b/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts @@ -436,7 +436,9 @@ function useCodeMirrorScope(view: EditorView) { if (cursorHighlights && currentDoc) { const items = cursorHighlights[currentDoc.doc_id] highlightsRef.current.cursorHighlights = items - view.dispatch(setCursorHighlights(items)) + window.setTimeout(() => { + view.dispatch(setCursorHighlights(items)) + }) } }, [view, cursorHighlights, currentDoc])