Unicode in JS is messy: https://code.google.com/p/v8/issues/detail?id=761#c33
miniblog.
Related Posts
I carefully document `cargo install --locked` for difftastic users, I carefully use `--locked` for CI, and I've just realised that all my release builds totally ignore it! Oops.
Anyone using my prebuilt binaries have been getting different Unicode width calculations in display.
On the challenge of writing accurate source spans on Unicode source code: https://reedmullanix.com/posts/unicode-source-spans.html
Also (see footnotes) a fair number of LSP clients assume UTF-8 despite early versions of LSP mandating UTF-16!
In LSP, a position is represented as a line number and a column offset (in Unicode code units): https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#position
This is pretty elegant. You'll get the correct line regardless of encoding bugs, and the editor already knows the line number so it's cheap to compute.