ronisbr / PrettyTables.jl

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

`vcrop_mode = :middle` breaks `AnsiTextCell` #207

Closed staticfloat closed 1 year ago

staticfloat commented 1 year ago

Example:

using PrettyTables

data = Dict(
    "A" => collect(1:100),
    "B" => [AnsiTextCell(iseven(x) ? "a️" : "b") for x in collect(1:100)]
)
pretty_table(data; vcrop_mode=:middle)

Output:

┌──────────────┬───────┐
│            B │     A │
│ AnsiTextCell │ Int64 │
├──────────────┼───────┤
│            b │     1 │
│            a️ │     2 │
│            b │     3 │
│            a️ │     4 │
│            b │     5 │
│            a️ │     6 │
│            b │     7 │
│            a️ │     8 │
│            b │     9 │
│            a️ │    10 │
│      ⋮       │   ⋮   │
│  │    91 │
│  │    92 │
│  │    93 │
│  │    94 │
│  │    95 │
│  │    96 │
│  │    97 │
│  │    98 │
│  │    99 │
│  │   100 │
└──────────────┴───────┘
         80 rows omitted

My guess is that some of the internal state of the AnsiTextCell gets confused due to the unusual control flow of vcrop_mode=:middle.

ronisbr commented 1 year ago

Thanks for the bug report! I will check what's happening.

ronisbr commented 1 year ago

Hi @staticfloat!

It should be working now. I will tag a new version as soon as the tests pass here:

julia> pretty_table(data; vcrop_mode=:middle)
┌──────────────┬───────┐
│            B │     A │
│ AnsiTextCell │ Int64 │
├──────────────┼───────┤
│            b │     1 │
│            a️ │     2 │
│            b │     3 │
│            a️ │     4 │
│            b │     5 │
│            a️ │     6 │
│            b │     7 │
│            a️ │     8 │
│            b │     9 │
│            a️ │    10 │
│            b │    11 │
│            a️ │    12 │
│            b │    13 │
│            a️ │    14 │
│            b │    15 │
│            a️ │    16 │
│            b │    17 │
│            a️ │    18 │
│      ⋮       │   ⋮   │
│            b │    83 │
│            a️ │    84 │
│            b │    85 │
│            a️ │    86 │
│            b │    87 │
│            a️ │    88 │
│            b │    89 │
│            a️ │    90 │
│            b │    91 │
│            a️ │    92 │
│            b │    93 │
│            a️ │    94 │
│            b │    95 │
│            a️ │    96 │
│            b │    97 │
│            a️ │    98 │
│            b │    99 │
│            a️ │   100 │
└──────────────┴───────┘
         64 rows omitted