Skip to content

FIX: stabilize diff algorithm for streaming #1358

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

Merged
merged 1 commit into from
May 22, 2025
Merged

Conversation

SamSaffron
Copy link
Member

Previous to this fix we would diff the entire body of text, this
could lead to situations where a diff presented to a user was
wildly off matching areas in the text that should not have been
tested.

New algorithm only checks a portion of the string, this ensures
that during streaming there is no chance for wild mistakes

Previous to this fix we would diff the entire body of text, this
could lead to situations where a diff presented to a user was
wildly off matching areas in the text that should not have been
tested.

New algorithm only checks a portion of the string, this ensures
that during streaming there is no chance for wild mistakes
Copy link
Contributor

@nattsw nattsw left a comment

Choose a reason for hiding this comment

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

This looks ok, good testing. I'm not sure if we'd want to add more test cases e.g.

  • original = "hello", target = "" (all text removed)
  • original = "hi cat", target = "hi cat" (whitespace)
  • original = "🏴‍☠️", target = "🏴" (zwj emojis)

@SamSaffron
Copy link
Member Author

Agree we can expand this

@SamSaffron SamSaffron merged commit 55dab9c into main May 22, 2025
6 checks passed
@SamSaffron SamSaffron deleted the improve-diff-flash branch May 22, 2025 06:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants