Skip to content
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

If the string contains Unicode Emoji, the index will be misaligned. #27

Open
tioken opened this issue Dec 10, 2021 · 1 comment
Open

Comments

@tioken
Copy link

tioken commented Dec 10, 2021

Hello, thanks for this useful library!

I'd like to report a bug that I encountered while using it.

 json0diff(['Hello'], ['🤗Hello🤗'], DiffMatchPatch, json1, textUnicode);
// Outputs => [0,{"es":["🤗",6,"🤗"]}]

When this is passed to the apply method of json1, an error message Error: The op is too long for this document will be displayed.

It seems that text-unicode treats emoji as a single character.
changing the index from 6 to 5 works fine.

 [0,{"es":["🤗",5,"🤗"]}]

If it is possible, could you please fix it?

@curran
Copy link
Collaborator

curran commented Dec 10, 2021

Aha! This is actually a flaw in the underlying JSON0 implementation. It is fixed in JSON1 - see https://github.com/ottypes/json1#interoperability-with-json0

Because of this, I'm not sure if it's even possible to fix this issue in this library.

However, a failing unit test would be a great first step.

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

No branches or pull requests

2 participants