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

UTF-16 and UTF-32 offsets #7

Closed
alicelogos opened this issue May 20, 2023 · 2 comments
Closed

UTF-16 and UTF-32 offsets #7

alicelogos opened this issue May 20, 2023 · 2 comments

Comments

@alicelogos
Copy link

Thanks for your work!

I like crop's API and consider using crop in a LSP server, however in LSP offsets can be UTF-8, UTF-16 or UTF-32, and LSP servers must support UTF-16 offsets.

According to crop's README:

crop doesn't currently implement those APIs but adding them would be extremely easy. If you need those features in your application please open an issue describing your use case.

So I open this issue. Hoping you could add UTF-16 and UTF-32 offsets support.

@noib3
Copy link
Collaborator

noib3 commented May 27, 2023

Thanks and sorry for the late response!

I'm open to adding some methods on Rope and RopeSlice that allow converting byte offsets to and from UTF-16 code unit offsets. UTF-32 is rarely used and not mandatory according to the LSP spec so I don't think I'll add that.

I've started working on this in #8, I'll ping you when it'll be ready to be merged.

@noib3
Copy link
Collaborator

noib3 commented May 29, 2023

#8 has just been merged to main, adding support for converting between UTF-16 and byte offsets by enabling the utf16-metric feature flag.

I consider this completed but feel free to re-open if you think there's something missing.

@noib3 noib3 closed this as completed May 29, 2023
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