ronisbr / PrettyTables.jl

Print data in formatted tables.
MIT License
391 stars 38 forks source link

AnsiTextCell overwrites following cells when `show_row_number` is set #208

Closed staticfloat closed 12 months ago

staticfloat commented 1 year ago

Example:

julia> using PrettyTables

       table = Dict(
           :x => ["totally not an a"],
           :xx => [AnsiTextCell("a")],
       )
       pretty_table(stdout, table; show_row_number = true)
┌─────┬──────────────┬──────────────────┐
│ Row │           xx │                x │
│     │ AnsiTextCell │           String │
├─────┼──────────────┼──────────────────┤
│   1 │            a │ a │
└─────┴──────────────┴──────────────────┘

Note how the second cell should not say a, it should say totally not an a. Also note how this is somewhat Dict-key-ordering-sensitive; if the AnsiTextCell comes as the last column, everything looks fine:

julia> using PrettyTables

       table = Dict(
           :xx => ["totally not an a"],
           :x => AnsiTextCell[AnsiTextCell("a")],
       )
       pretty_table(stdout, table; show_row_number = true)
┌─────┬──────────────────┬──────────────┐
│ Row │               xx │            x │
│     │           String │ AnsiTextCell │
├─────┼──────────────────┼──────────────┤
│   1 │ totally not an a │            a │
└─────┴──────────────────┴──────────────┘
ronisbr commented 12 months ago

Ops! I missed that notification. Thanks @staticfloat, let me see what's happening here.

ronisbr commented 12 months ago

Done! I was a regression due to the last commit. The problem is that I have three types of indices:

  1. The index of the data in the original table.
  2. The index of the data in the processed table (with additional columns).
  3. The index of the data in the string table considering the cropping.

I always get confused with those things :)

Thank you very much for the report.

staticfloat commented 12 months ago

Awesome! I really appreciate how quick you are to deal with these reports, thank you!