Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Character offsets from the client are utf-16 code units #630

Closed
Marwes opened this issue Dec 16, 2017 · 4 comments
Closed

Character offsets from the client are utf-16 code units #630

Marwes opened this issue Dec 16, 2017 · 4 comments

Comments

@Marwes
Copy link

Marwes commented Dec 16, 2017

The language server protocol specifies that that character positions are in UTF-16 code units (see https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#text-documents). I encountered this after crashing https://github.com/gluon-lang/gluon_language-server due to accidentally typing a multi byte character.

While tracking down what character was supposed to mean for the protocol I also looked at what rls did to see if there was a easy way to handle this but from what I understand from the source I don't think this is handled in any way.

https://github.com/rust-lang-nursery/rls/blob/9782aa4c3c5b203732b9a1a4f3c9d7fbc912e437/src/actions/requests.rs#L1005

https://github.com/rust-lang-nursery/rls/blob/41bf9af09ccc9cbbe8a67a375f0f7fe3196dbabf/src/lsp_data.rs#L100

Feel free to just close this If I am mistaken, I figured I'd at least open an issue in case this needs to be handled.

@Xanewok
Copy link
Member

Xanewok commented Jan 18, 2018

Related discussion: microsoft/language-server-protocol#376

@Marwes
Copy link
Author

Marwes commented Jan 18, 2018

FWIW this is the location translation I am using https://github.com/gluon-lang/gluon_language-server/blob/master/src/location_translation.rs (manually using encode_utf16 and len_utf16)

@Xanewok
Copy link
Member

Xanewok commented Dec 11, 2018

Everything old is new again: #1113

@Xanewok
Copy link
Member

Xanewok commented Mar 2, 2019

The aforementioned issue has more recent information so I'll close this as duplicate.

@Xanewok Xanewok closed this as completed Mar 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants