From 2cef54dcf37316be283ea46222b484a3f36657e9 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Fri, 31 May 2024 11:50:30 +0200 Subject: [PATCH] Store DOM mutation status in DOMChange objects --- src/domchange.ts | 2 ++ src/domobserver.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/domchange.ts b/src/domchange.ts index 1aa80bf..a456dc2 100644 --- a/src/domchange.ts +++ b/src/domchange.ts @@ -15,8 +15,10 @@ export class DOMChange { } | null = null text: string = "" newSel: EditorSelection | null + domChanged: boolean constructor(view: EditorView, start: number, end: number, readonly typeOver: boolean) { + this.domChanged = start > -1 let {impreciseHead: iHead, impreciseAnchor: iAnchor} = view.docView if (view.state.readOnly && start > -1) { // Ignore changes when the editor is read-only diff --git a/src/domobserver.ts b/src/domobserver.ts index 4b4f065..92a3e7d 100644 --- a/src/domobserver.ts +++ b/src/domobserver.ts @@ -381,7 +381,7 @@ export class DOMObserver { let handled = applyDOMChange(this.view, domChange) // The view wasn't updated but DOM/selection changes were seen. Reset the view. if (this.view.state == startState && - (domChange.bounds || domChange.newSel && !domChange.newSel.main.eq(this.view.state.selection.main))) + (domChange.domChanged || domChange.newSel && !domChange.newSel.main.eq(this.view.state.selection.main))) this.view.update([]) return handled }