-
-
Notifications
You must be signed in to change notification settings - Fork 145
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
Got 'panic: offset should be less than or equal to length' when inserting emoji #110
Comments
Yes, that's the issue. In Golang for some unicode characters, if you count character by len, the result might not be as expected. This post in SO might be useful as a reference. Just found out that an emoji length in JS is commonly 2, while in Go it is 4. But yeah, not always, it varies, e.g. "🇦🇬".length = 4, "🏴".length = 12. |
I'm not fully grasped the side effect yet as I'm still exploring the codebase. It seems, changing yorkie/pkg/document/json/rga_tree_split.go Lines 298 to 301 in efd0e5f
if offset > node.contentLen() {
// Instead of panicking let's just assume offset = content len here.
offset = node.contentLen()
} will solve the issue (tested via the Quill example). @hackerwins do you think this will popup another issue? |
Thank you for thinking about the solution. But the suggestion could bypass the panic, but it doesn't seem to fix the underlying cause. I think the problem will be solved if yorkie/pkg/document/json/rich_text.go Lines 67 to 72 in efd0e5f
yorkie/pkg/document/json/rich_text.go Lines 55 to 57 in efd0e5f
In JS SDK |
@habibrosyad Thanks to you, we fixed an important issue. |
What happened:
I got a panic error in the agent when trying to insert emoji in the Quill example.
What you expected to happen:
No error occurred.
How to reproduce it (as minimally and precisely as possible):
Try to insert/copy-paste an emoji, then repeat it again 1 more time.
Anything else we need to know?:
Below are the logs snippet:
Environment:
yorkie version
): master branchThe text was updated successfully, but these errors were encountered: