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

Properly support position encodings #107

Open
mkaput opened this issue Dec 18, 2024 · 1 comment
Open

Properly support position encodings #107

mkaput opened this issue Dec 18, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mkaput
Copy link
Member

mkaput commented Dec 18, 2024

@mkaput commented on 11.06.2024, 14:29:48:

LS is not aware of and thus is not performing position encoding kind negotiation, which means the language client will assume UTF-16. Actually, LS is using UTF-8 because that's the native encoding of Rust strings. This means bad things can happen if files contain non-ASCII characters, especially ones like Emoji, which span multiple Unicode codepoints.

Things to implement:

  • Properly negotiate position encoding with the language client. Prefer UTF-8 to avoid re-encoding files, but fall back to UTF-16 as this is the only encoding guaranteed to be universally supported by clients.
  • When converting Cairo positions to LSP ones, take into account encoding differences. This will require knowing file source at conversion time, which will be a large refactoring.
  • Enforce UTF-8 encoding in E2E tests (add appropriate asserts in MockClient).
@mkaput mkaput added the bug Something isn't working label Dec 18, 2024
@mkaput
Copy link
Member Author

mkaput commented Dec 18, 2024

@mkaput commented on 9.07.2024, 13:36:18:

Using https://docs.rs/line-index/latest/line_index/ for line counting instead of custom code may enable this.

@github-project-automation github-project-automation bot moved this to Triage in CairoLS Dec 18, 2024
@mkaput mkaput moved this from Triage to Backlog in CairoLS Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

1 participant