-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Trailing comments misplaced #53
Comments
Yup, this is a bug, I'm working on a fix :) |
v0.11 is out with a fix, please let me know if you're still experiencing this issue |
Thank you for the fix (and also for the amazing library! ❤️) but it looks like the bug persists for lists (and maybe also for some other contexts). Let [
a()
# test
]
[
a()
# test
] Whereas [
a()
# test
] |
Hi @doorgan in The following script shows the issue: Mix.install([{:sourceror, "~> 0.14"}])
code = """
[
:field_1,
#######################################################
### Another comment
#######################################################
:field_2
]
"""
write = fn code, i ->
IO.puts("--- code #{i} ---\n#{code}\n")
code
end
format = fn code ->
code
|> Sourceror.parse_string!()
|> Sourceror.to_string()
end
Enum.reduce(0..4, code, fn i, code ->
code
|> write.(i)
|> format.()
end)
|
Given the following source code in file
bug.ex
:When we execute the following
File.read!("bug.ex") |> Sourceror.parse_string!() |> Sourceror.to_string() |> IO.puts()
, then the output is:However, when we run
File.read!("bug.ex") |> Code.format_string!() |> IO.iodata_to_binary() |> IO.puts()
, then the output is:If I understood correctly, then Sourceror should format the code the same way as Elixir formatter which does not seem to be the case here.
The text was updated successfully, but these errors were encountered: