From 5269bbad66f6ad8cda9bdb9baccbe12e5730f851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Trzci=C5=84ski?= Date: Mon, 30 Sep 2024 11:01:45 +0200 Subject: [PATCH] [#64933] fix heading fold on load in large documents --- src/extensions/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/extensions/index.js b/src/extensions/index.js index c4c131e..956c49b 100644 --- a/src/extensions/index.js +++ b/src/extensions/index.js @@ -9,7 +9,7 @@ import { customHighlighter } from "./customHighlights"; import { commentExtension } from "../comments"; import { commentAuthoring } from "../comments/lineAuthors"; import { suggestionPopup } from "./suggestions"; -import { foldEffect, unfoldEffect, foldable } from "@codemirror/language"; +import { foldEffect, unfoldEffect, foldable, ensureSyntaxTree } from "@codemirror/language"; import { syncPreviewWithCursor } from "./syncDualPane"; import { cursorIndicator } from "./cursorIndicator"; import { customCommonMark, fenceFold, headerIndent } from "./markdownLang"; @@ -227,6 +227,8 @@ export class ExtensionBuilder { /** This function folds all top level syntax nodes, while skiping a number of them defined by the `skip` parameter */ export function skipAndFoldAll(/** @type {EditorView} */ view, skip = 0) { + ensureSyntaxTree(window.myst_editor.main_editor.state, view.state.doc.length, 5000); + view.dispatch({}); let { state } = view; let effects = []; let nProcessedFoldables = 0;