exsamples
exsamples copied to clipboard
Long table is not formatted properly
The following code:
samples do
:id | :name | :currency | :language | :population | :inflation | :continent | :main_sport | :independence_day
1 | "Brazil" | "Real (BRL)" | "Portuguese" | 204451000 | 7.70 | "South America" | "Football" | ~D["1822-09-07"]
end
is formatted like this:
samples do
:id | :name | :currency | :language | :population | :inflation | :continent | :main_sport | :independence_day
1
| "Brazil"
| "Real (BRL)"
| "Portuguese"
| 204_451_000
| 7.70
| "South America"
| "Football"
| ~D["1822-09-07"]
end
Here is a test that reproduce the error
test "very long table" do
code = """
samples do
:id | :name | :currency | :language | :population | :inflation | :continent | :main_sport | :independence_day
1 | "Brazil" | "Real (BRL)" | "Portuguese" | 204451000 | 7.70 | "South America" | "Football" | ~D["1822-09-07"]
end
"""
assert Samples.FormatterPlugin.format(code, []) == """
samples do
:id | :name | :currency | :language | :population | :inflation | :continent | :main_sport | :independence_day
1 | "Brazil" | "Real (BRL)" | "Portuguese" | 204_451_000 | 7.70 | "South America" | "Football" | ~D["1822-09-07"]
end
"""
end
I am suspecting the line_length to be the cause of this behaviour.
I believe we should override the line_length to properly render the table. WDYT? ping @msaraiva
Yeah, the problem is that we need to run the Elixir formatter before we run ours, keeping its original behavior, including the line length. We need to find another way to do that. Maybe something like:
- read the original tables
- run the Elixir formatter
- replace the wrongly formatted tables with the original ones
- run our formatter
Any other suggestion?