mirror of
https://github.com/heyman/heynote.git
synced 2024-11-21 15:33:14 +01:00
Fix error on startup when cursor is moved to the end of a large buffer (caused by the syntaxTree not being parsed in time)
This commit is contained in:
parent
971f406720
commit
8626dcc141
@ -1,6 +1,6 @@
|
||||
import { Annotation, EditorState, Compartment, Facet } from "@codemirror/state"
|
||||
import { EditorView, keymap, drawSelection, ViewPlugin, lineNumbers } from "@codemirror/view"
|
||||
import { indentUnit, forceParsing, foldGutter } from "@codemirror/language"
|
||||
import { indentUnit, forceParsing, foldGutter, ensureSyntaxTree } from "@codemirror/language"
|
||||
import { markdown } from "@codemirror/lang-markdown"
|
||||
import { closeBrackets } from "@codemirror/autocomplete";
|
||||
|
||||
@ -116,6 +116,10 @@ export class HeynoteEditor {
|
||||
parent: element,
|
||||
})
|
||||
|
||||
// Ensure we have a parsed syntax tree when buffer is loaded. This prevents errors for large buffers
|
||||
// when moving the cursor to the end of the buffer when the program starts
|
||||
ensureSyntaxTree(state, state.doc.length, 5000)
|
||||
|
||||
if (focus) {
|
||||
this.view.dispatch({
|
||||
selection: {anchor: this.view.state.doc.length, head: this.view.state.doc.length},
|
||||
|
Loading…
Reference in New Issue
Block a user