Everything works pretty well when Golang server implements codemirror/state text.ts in Go language and uses utf8.RuneCountInString, which counts how many characters there are in a string. It works very well even with many unicode characters, but now when I tested it with emoji unicode characters that you can type e.g. on MacOS like , Javascript string length starts to differ.
‘’.length is 2 and that doesn’t any longer match with rune length in Go that is 1 and applying ChangeSet fails.
I tried a quick test to fork codemirror/state and change anything related to line.length and line.slice to
export function getCharacterLength(str: string) {
return [...str].length
}
export function sliceByCharacterLength(str: string, from: number, to?: number) {
if (!to) {
to = -1
}
return [...str].slice(from, to).join('');
}
But that wasn’t a solution for this, since there are other places that uses string length to access text.
Would you have any ideas what kind of solutions could be tested out?