Skip to content

Conversation

@Madhawa97
Copy link

Description:
This PR fixes #79
The plugin now rebuilds the ChangeSet from the current EditorState before running inconsistency fixes.

Changes:

  • Rebuild changeSet from state.doc before calling fixInconsistentChanges in packages/manuscripts-track-changes-plugin/src/plugin.ts

Testing:

  1. In the editor create a tracked deletion, type inside it (e.g. "AB"). Confirm result is AB adjacent to the delete (no nested marks).
image 2. Confirm no console warnings about inconsistent changes. 3. Run existing test suite.

Notes for reviewer:

  • No behaviour changes intended besides removing the inconsistency case. Please review and test throughly.

Copilot AI review requested due to automatic review settings October 27, 2025 14:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 EditorState from prosemirror-state to enable changeSet rebuilding
  • Rebuild changeSet from current document state when createdTr.docChanged is true before calling fixInconsistentChanges

💡 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 }))
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
setAction(createdTr, TrackChangesAction.refreshChanges, true)
}
})

Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested tracked marks and invalid change ranges when typing inside deletions

1 participant