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

Respect client's preferred encoding when possible #446

Merged
merged 1 commit into from
Apr 7, 2024

Conversation

nthykier
Copy link
Contributor

@nthykier nthykier commented Apr 6, 2024

Description (e.g. "Related to ...", etc.)

Related to #445

This change would make pygls accept the client's preferred encoding rather than preferring UTF-16 blindly. For editors that prefer UTF-32 this is advantageous for pygls since the position encoding/decoding becomes simpler.

Code review checklist (for code reviewer to complete)

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Commit messages are meaningful (see this for details)
  • Tests have been included and/or updated, as appropriate
  • Docstrings have been included and/or updated, as appropriate
  • Standalone docs have been updated accordingly

Previously, `pygls` would always use `UTF-16` except when the client
tried to hide the fact that it supports `UTF-16` (which the LSP spec
requires it to do in all cases). Now, `pygls` will choose the editor's
preferred encoding.

When it is `UTF-32`, `pygls` saves a bit of computation in most
position codec related operations (`X_to_client_units` +
`client_num_units` are faster, `X_from_client_units` is about the
same), which is great. When it is `UTF-16` or `UTF-8`, the
computational load is about the same.

Closes: openlawlibrary#445
@tombh tombh self-requested a review April 7, 2024 18:29
@tombh
Copy link
Collaborator

tombh commented Apr 7, 2024

Thank you. I'll merge it now so it's available on the main branch. I won't cut a release immediately. But if you want a release soonder, please feel free to let us know.

@tombh tombh merged commit 0d51815 into openlawlibrary:main Apr 7, 2024
16 checks passed
@nthykier nthykier deleted the fix-445 branch April 7, 2024 18:45
@nthykier
Copy link
Contributor Author

nthykier commented Apr 7, 2024

Thanks for the merge. No urgent need for this released. :)

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

Successfully merging this pull request may close these issues.

2 participants