Don't emit event if we did not get an active block (can happen with extremely large blocks, most likely because of slow syntax tree parsing)

This commit is contained in:
Jonatan Heyman 2023-01-19 23:41:39 +01:00
parent aa628a4f08
commit 6c1e89c5b0

View File

@ -285,11 +285,13 @@ const emitCursorChange = (editor) => ViewPlugin.fromClass(
if (update.selectionSet || langChange) {
const cursorLine = getBlockLineFromPos(update.state, update.state.selection.main.head)
const block = getActiveNoteBlock(update.state)
editor.element.dispatchEvent(new SelectionChangeEvent({
cursorLine,
language: block?.language.name,
languageAuto: block?.language.auto,
}))
if (block) {
editor.element.dispatchEvent(new SelectionChangeEvent({
cursorLine,
language: block.language.name,
languageAuto: block.language.auto,
}))
}
}
}
}