From 6f6bec5764f5071f5d8b9e94492cd62beeb196bd Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Fri, 23 Aug 2024 14:09:28 -0700 Subject: [PATCH] Force codemirror to parse more to be able to show code folding --- src-web/components/core/Editor/Editor.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src-web/components/core/Editor/Editor.tsx b/src-web/components/core/Editor/Editor.tsx index 0c69a66c..682891a9 100644 --- a/src-web/components/core/Editor/Editor.tsx +++ b/src-web/components/core/Editor/Editor.tsx @@ -1,4 +1,5 @@ import { defaultKeymap } from '@codemirror/commands'; +import { forceParsing } from '@codemirror/language'; import { Compartment, EditorState, type Extension } from '@codemirror/state'; import { keymap, placeholder as placeholderExt, tooltips } from '@codemirror/view'; import type { EnvironmentVariable, TemplateFunction } from '@yaakapp/api'; @@ -297,6 +298,12 @@ export const Editor = forwardRef(function E }); view = new EditorView({ state, parent: container }); + + // For large documents, the parser may parse the max number of lines and fail to add + // things like fold markers because of it. + // This forces it to parse more but keeps the timeout to the default of 100ms. + forceParsing(view, 9e6, 100); + cm.current = { view, languageCompartment }; if (autoFocus) { view.focus();