-
Notifications
You must be signed in to change notification settings - Fork 196
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 Formatting.format returns character float number #250
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Just one suggestion.
@@ -81,7 +81,7 @@ defmodule ElixirLS.LanguageServer.Providers.Formatting do | |||
else | |||
# LSP contentChanges positions are based on UTF-16 string representation | |||
# https://microsoft.github.io/language-server-protocol/specification#textDocuments | |||
{line, col + byte_size(:unicode.characters_to_binary(char, :utf8, :utf16)) / 2} | |||
{line, col + trunc(byte_size(:unicode.characters_to_binary(char, :utf8, :utf16)) / 2)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to use Kernel.div/2
instead?
@axelson your suggestion was addressed. CI fail because of dialyzer test. I think this is not related with this changes. |
This bug happens because of use `/ 2` in advance_pos which is convert into floating number. Fixes by using `trunc/1`. And add test to ensure line and character always integer. Fixes elixir-lsp#249
@x-ji commit was squash and ci are all green. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the change! ❤️
The CI tests are a little flaky sometimes.
This bug happens because of use
/ 2
in advance_pos which is convertinto floating number. Fixes by using
trunc/1
. And add test to ensureline and character always integer.
Fixes #249