fix(editor): Fix Code node bug erasing and overwriting code when switching between nodes (#12637)

Co-authored-by: Elias Meire <elias@meire.dev>
This commit is contained in:
Alex Grozav
2025-01-16 19:36:08 +02:00
committed by GitHub
parent 0b0f532367
commit 02d953db34
4 changed files with 143 additions and 5 deletions

View File

@@ -1,14 +1,19 @@
import { Annotation } from '@codemirror/state';
import type { EditorView } from '@codemirror/view';
export const ignoreUpdateAnnotation = Annotation.define<boolean>();
/**
* Simulate user action to force parser to catch up during scroll.
*/
export function forceParse(view: EditorView) {
view.dispatch({
changes: { from: view.viewport.to, insert: '_' },
annotations: [ignoreUpdateAnnotation.of(true)],
});
view.dispatch({
changes: { from: view.viewport.to - 1, to: view.viewport.to, insert: '' },
annotations: [ignoreUpdateAnnotation.of(true)],
});
}