Formatting the following code
samples do
:fuel_type | :co2 | :year | :percentage
# 2020
:diesel | 105 | 2020 | 0.069
end
Will result in:
samples do
:fuel_type | :co2 | :year | :percentage
# 2020----
:diesel | 105 | 2020 | 0.069
end
WIth 4 whitespaces after # 2020. I represented them with -
Here is a test that reproduces the bug:
test "handle comments" do
code = """
samples do
:fuel_type | :co2 | :year | :percentage
# 2020
:diesel | 105 | 2020 | 0.069
:petrol | 110 | 2020 | 0.054
end
"""
assert Samples.FormatterPlugin.format(code, []) == """
samples do
:fuel_type | :co2 | :year | :percentage
# 2020
:diesel | 105 | 2020 | 0.069
:petrol | 110 | 2020 | 0.054
end
"""
end
This is due to the offset we add to the first column
|
{col_index, value} -> |
|
offset = if col_index == 0, do: String.duplicate(" ", column_offset), else: "" |
|
offset <> align_value(value, cols_info[col_index], false) |
A solution could be to pattern match on # in the walk function.
Formatting the following code
Will result in:
WIth 4 whitespaces after
# 2020. I represented them with-Here is a test that reproduces the bug:
This is due to the offset we add to the first column
exsamples/lib/formatter_plugin.ex
Lines 122 to 124 in 3722216
A solution could be to pattern match on
#in thewalkfunction.