Add position encoding negotiation support#4
Merged
Conversation
LSP 3.17 lets the client and server negotiate how positions are encoded (what column offsets mean), rather than always assuming UTF-16. - Add PositionEncodingKind (utf-8 / utf-16 / utf-32) per the spec's base type. - Add GeneralClientCapabilities so clients can advertise supported encodings via general.positionEncodings, wired into ClientCapabilities. - Add ServerCapabilities carrying the server-chosen positionEncoding. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
christiankissig
added a commit
that referenced
this pull request
Jul 7, 2026
Add position encoding negotiation support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for position encoding negotiation as introduced in LSP 3.17 — Text Documents.
Prior to 3.17, all positions (column offsets) were assumed to be UTF-16 code units. Since 3.17 the client and server can agree on a different encoding:
general.positionEncodingscapability.positionEncodingserver capability. If there is no match, UTF-16 is the mandatory default.Changes
PositionEncodingKind— string enum withutf-8/utf-16/utf-32, matching the spec's base type.GeneralClientCapabilities— new model exposingpositionEncodings(plus the other general sub-capabilities); wired intoClientCapabilities.general(previously a baredict).ServerCapabilities— new model carrying the negotiatedpositionEncoding.lsp_client.Testing
InitializeRequestwire output, and the server capability.poetry run pytest(38 passed),ruff check,ruff format --check, andmypyall clean.🤖 Generated with Claude Code