Positions are UTF-8 byte offsets while positionEncoding says utf-16
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- ruby
- Domain
- developer-experience, tooling
Research direction
Start from the InitializeResult where positionEncoding is advertised, then trace how textDocument/references, definition, hover and diagnostics convert character offsets; compare that path with the ranged didChange sync path that already handles UTF-16. Reproduce with the a.rb snippet and check the call site on line 5 at UTF-16 column 19 versus UTF-8 byte column 22. Done means those requests and diagnostics use UTF-16 code units, with regression tests covering non-ASCII text before a token.
Written by the indexing model from the issue text.
Description
Version: ruby-lsp 0.26.11, Ruby 4.0.3, Linux x86_64, a plain stdio LSP client (not VS Code).
What happens. The server's InitializeResult advertises positionEncoding: "utf-16", whether the
client offers general.positionEncodings: ["utf-16"] or no positionEncodings at all. On a line with
non-ASCII text before a token, the character it returns and reads is a UTF-8 byte offset, not a
UTF-16 code-unit offset.
Repro. a.rb:
class Foo
def self.helper
1
end
def self.run
s = "é😀"; Foo.helper
end
end
On line 5, helper starts at UTF-16 column 19 (UTF-8 byte 22, code point 18).
textDocument/referencesat the definition (line 1, character 11) returns the call site at
line 5, character 22.textDocument/definitionandtextDocument/hoverat line 5, character 20 (insidehelper
in UTF-16) return nothing. At character 23 (inside it in UTF-8 bytes), definition goes to line 1
and hover showshelper().- Diagnostics on such lines are also placed at byte offsets.
Expected. UTF-16 code units, as advertised, or advertising utf-8 when the client offers it.
Note. A whole-document ranged didChange whose end is computed in UTF-16 is applied
correctly, so the document sync path seems to convert; requests and responses don't.
Possibly related: #4180 (completion after Unicode in an interpolated string) and #4094 (RuboCop
quickfix with multi-byte characters).
- Dominant language
- Ruby
- Stars
- 2k
- Forks
- 300
- Avg merge
- 2h 54m
- Merged PRs (30d)
- 9
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/ruby-lsp
-
Bundler settings containing spaces are rewritten with colons when composing the bundlePossibly taken @efegokdemir claimed this 5 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Shopify/ruby-lsp#4275 · 1 comment · 3 reactions ·
Maintainers usually reply within 1 day
-
Dependencies view: `getParent` loops forever on untitled documents, extension host runs out of memoryPossibly taken @efegokdemir claimed this 44 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Linux file system with square brackets in the directory/filename are failing to be indexedPossibly taken @andriytyurnikov claimed this 249 days ago. Openbug help-wanted pinned
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Shopify/ruby-lsp#3503 · 9 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
Composed bundle rewrites project binstubs when Bundler bin is setPossibly taken @efegokdemir claimed this 1 day ago. Openbug
Difficulty 3/5 1-2 days Newbie friendliness 42/100
Maintainers usually reply within 1 day
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
All issues in Shopify/ruby-lsp
Similar issues
-
Generated cask uses deprecated `postflight` stanza; Homebrew 7 warns on every commandPossibly taken @k4kratik claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
sachincool/cruft#4 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
riscv/riscv-unified-db#2859 ·
Maintainers usually reply within 2 days
-
changesets
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openstreetmap/openstreetmap-website#7629 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
we-promise/sure#5742 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
itinance/react-native-fs#1270 ·