Skip to content
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

Long table is not formatted properly #6

Open
Malian opened this issue Jun 2, 2022 · 1 comment
Open

Long table is not formatted properly #6

Malian opened this issue Jun 2, 2022 · 1 comment

Comments

@Malian
Copy link
Contributor

Malian commented Jun 2, 2022

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

@msaraiva
Copy link
Owner

msaraiva commented Jun 2, 2022

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:

  1. read the original tables
  2. run the Elixir formatter
  3. replace the wrongly formatted tables with the original ones
  4. run our formatter

Any other suggestion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants