Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an inconsistency issue (#79) where the plugin was attempting to fix changes based on an outdated changeSet. The fix ensures that the changeSet is rebuilt from the current document state before running inconsistency checks, preventing nested marks when typing inside tracked deletions.
Key changes:
- Import
EditorStatefrom prosemirror-state to enable changeSet rebuilding - Rebuild changeSet from current document state when
createdTr.docChangedis true before callingfixInconsistentChanges
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }) | ||
|
|
||
| const currentChangeSet = createdTr.docChanged | ||
| ? findChanges(EditorState.create({ doc: createdTr.doc, schema: oldState.schema })) |
There was a problem hiding this comment.
Creating a temporary EditorState just to call findChanges is inefficient and bypasses the normal state lifecycle. Consider refactoring findChanges to accept a document and schema directly, or use the existing state management pattern in the plugin.
| setAction(createdTr, TrackChangesAction.refreshChanges, true) | ||
| } | ||
| }) | ||
|
|
There was a problem hiding this comment.
Add a comment explaining why the changeSet needs to be rebuilt from the current document state before fixing inconsistencies. This will help future maintainers understand the purpose of this rebuild step and its relationship to issue #79.
| // Rebuild the changeSet from the current document state if the document has changed. | |
| // This is necessary before fixing inconsistencies to ensure that the changeSet accurately reflects | |
| // the latest document state, preventing issues where inconsistencies are missed or incorrectly handled. | |
| // See issue #79 for details on why this step is required. |
Description:
This PR fixes #79
The plugin now rebuilds the ChangeSet from the current EditorState before running inconsistency fixes.
Changes:
Testing:
Notes for reviewer: