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
fix(prisma-fmt): use UTF-16 offset in the response for the schema that contains multi-byte characters #4815
base: main
Are you sure you want to change the base?
Conversation
CodSpeed Performance ReportMerging #4815 will not alter performanceComparing Summary
|
There are warnings about dead_code for many functions in |
@key-moon this happens because the module is included twice in both the library crate and the binary crate. I see that some existing modules in this package follow this pattern too but it's not really the best way to do it. Aside from leading to problems like the one you encountered, it will also lead to compiling the same code twice and potentially bloating the binary (for us maybe there's no binary size impact because The way it's normally done in Rust is you only include such modules in the library crate (i.e. in |
Understood. I am new to Rust, so your help with the basics was very helpful. While applying the suggested fix, I ran into a problem caused by the fact that This could be solved by not including Edit: I just pushed the fix that was described above. I'm not sure whether this fix was the right way to do it. |
The error caused by the conflict has been resolved. It took some time to resolve, but now this PR is back to a problem-free state. |
Is there anything you are having trouble with for the merge? If there is, I will work towards resolving it. |
The current Prisma's LSP cannot handle schemas containing multibyte characters correctly.
This is because the offsets returned by prisma-fmt are calculated based on the number of bytes in UTF-8 encoding. In the LSP protocol, text offsets should be represented by the length in UTF-16 unless otherwise specified.
This pull request includes changes to the
offset_to_position
andposition_to_offset
functions, as well as the implementation of theoffset_to_lsp_offset
function and its usage withinlint::run
.This fixes the above issue.