tools icon indicating copy to clipboard operation
tools copied to clipboard

fix(rome_lsp): improve the handling of UTF-8 and overflow errors in `LineIndex`

Open leops opened this issue 3 years ago • 1 comments

Summary

Fixes #3733

This PR ensures the LineIndex utility (used to convert between the LineCol and TextSize representations of text positions within the language server) correctly accounts for UTF-8 character boundaries by properly converting between column numbers and byte offsets instead of directly reinterpreting each value kind as the other. I've also introduced additional error checking (especially in the line_col method that's not failible just like offset) to ensure that invalid text positions properly return None rather than an invalid offset (or panic)

Test Plan

I've added new test cases for LineIndex to check the result of both offset and line_col with various kinds of valid or invalid input

leops avatar Nov 15 '22 13:11 leops

Deploy Preview for docs-rometools canceled.

Name Link
Latest commit ae8c509389739049cfc45f1f47c917079f11ac8b
Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/63739b5dd80bdf00084cfdfb

netlify[bot] avatar Nov 15 '22 14:11 netlify[bot]