From a5e3ac8ec446dcfbea9ac2d8f5e74349c36069b6 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Fri, 19 Apr 2024 14:15:33 -0400 Subject: [PATCH] Reverse changeset --- src/completionDecoration.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/completionDecoration.ts b/src/completionDecoration.ts index 65cf13d..88c4b8a 100644 --- a/src/completionDecoration.ts +++ b/src/completionDecoration.ts @@ -38,6 +38,17 @@ export const completionDecoration = StateField.define({ } } + if (state) { + // If we ever have a state that is being updated, + // map it through the new changes to avoid the potential + // of a mismatch between it and the new document and new + // document length + return { + decorations: state.decorations.map(transaction.changes), + reverseChangeSet: state.reverseChangeSet.map(transaction.changes), + }; + } + return state; }, provide: (field) =>