Skip to content

Commit

Permalink
[#64933] fix heading fold on load in large documents
Browse files Browse the repository at this point in the history
  • Loading branch information
Trzcin committed Sep 30, 2024
1 parent 03a839a commit 5269bba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/extensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5269bba

Please sign in to comment.