-
Notifications
You must be signed in to change notification settings - Fork 46
feat: add command for generating diff between documents (SD-89) #1615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This function can then be reused when diffing paragraphs and runs. It helps identifying modifications instead of delete/insert pairs
Always maps starting/ending positions to the old document instead of the new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (isParagraphNodeInfo(oldNodeInfo) && isParagraphNodeInfo(newNodeInfo)) { | ||
| return shouldProcessEqualParagraphsAsModification(oldNodeInfo, newNodeInfo); | ||
| } | ||
| return JSON.stringify(oldNodeInfo.node.attrs) !== JSON.stringify(newNodeInfo.node.attrs); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-paragraph content changes never emitted
For non-paragraph nodes the comparator falls through to true whenever the type matches, and this block only flags an "equal" pair as modified when their attrs JSON differs. Any content edits inside a same-typed node that keeps its attributes (e.g., changing the text of a heading) will therefore be treated as unchanged and no diff is emitted, so callers will miss real document changes. Consider comparing child content (or the node’s JSON) instead of only attrs for non-paragraph nodes.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not the case because all of the descendants are iterated, not only container nodes. If a child of a node was modified, the diffing algorithm will pick it up.
What’s in this PR
computeDiffentry point that returns document-level diffs plus comment diffs.How the diffing computation works
Notes / rationale
Testing