Repository navigation
fix(lsp): Convert LSP positions to each client's offset encoding - #49
Merged
Merged
Conversation
…coding LSP requests sent the cursor's byte column as the position character and used the response characters as byte columns, so on lines with Japanese text or emoji a UTF-16 server received the wrong position and popups opened on the wrong column. - Convert the request position into each client's offset_encoding and convert every returned range, including document symbols, back to byte columns using the loaded buffer or the file on disk. - Keep all internal locations in byte columns so the same-position filter compares the cursor and results in one unit. - Cover UTF-8 / UTF-16 / UTF-32, multiple clients, unloaded files and requests from a copy popup.
LocationLink results used targetRange, which spans the whole symbol, so popups opened at the start of the declaration instead of its name, and a request from inside a function body was dropped as the same position. The link's selection range is now the location range for both navigation and the same-position filter, and the unused originSelectionRange copy, kept in client units, is no longer stored.
Column conversion read unloaded files byte for byte and matched loaded buffers by exact URI, so a UTF-8 BOM shifted the first line, and a symlinked or differently escaped URI fell back to stale disk text instead of the unsaved buffer. - Strip the BOM and CRs when reading unloaded files, and match loaded buffers by resolved path as well as by URI. - Convert inside the per-response pcall so a malformed response no longer discards that client's slot and delays completion until the timeout. - Cover multiline ranges, LocationLink selection ranges and malformed responses alongside valid clients.
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
offset_encoding, so popups open on the right column on lines with Japanese text or emoji.targetSelectionRangeinstead of the wholetargetRange.Changes
originSelectionRangecopy, kept in client units, is no longer stored.