tty-table icon indicating copy to clipboard operation
tty-table copied to clipboard

Top border is not indented correctly when table has no headers

Open rogermarlow opened this issue 1 year ago • 1 comments

Describe the problem

When rendering a table with an indent, if the table has no headers then the top border is not indented.

Steps to reproduce the problem

require 'tty-table'

ok = TTY::Table.new(header: ["H1","H2","H3"])
ok << ["a1","a2","a3"]
ok << ["b1","b2","b3"]

puts ok.render(:ascii, indent: 12)

broken = TTY::Table.new
broken << ["a1","a2","a3"]
broken << ["b1","b2","b3"]

puts broken.render(:ascii, indent: 12)

Actual behaviour

            +--+--+--+
            |H1|H2|H3|
            +--+--+--+
            |a1|a2|a3|
            |b1|b2|b3|
            +--+--+--+
+--+--+--+
            |a1|a2|a3|
            |b1|b2|b3|
            +--+--+--+

Expected behaviour

            +--+--+--+
            |H1|H2|H3|
            +--+--+--+
            |a1|a2|a3|
            |b1|b2|b3|
            +--+--+--+
            +--+--+--+
            |a1|a2|a3|
            |b1|b2|b3|
            +--+--+--+

Describe your environment

  • OS version: Darwin Kernel Version 23.2.0
  • Ruby version: v3.2.1
  • TTY::Table version: 0.12.0

rogermarlow avatar Mar 14 '24 22:03 rogermarlow

I have raised PR #44 to fix this.

rogermarlow avatar Mar 14 '24 22:03 rogermarlow