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

Fix indent bug for tables without headers (issue piotrmurach/tty-table/issues/45)

Open rogermarlow opened this issue 1 year ago • 1 comments

Describe the change

There is a bug rendering tables without headers with an indent. The top border is not indented.

Why are we doing this?

Bug fix.

Benefits

Bug fix.

Drawbacks

None.

Here is come code that demonstrates the problem:

require 'tty-table'

ok = TTY::Table.new(header: ["Home","H","A","Away"])
ok << ["team1",1,2,"team2"]
ok << ["team3",0,1,"team4"]

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

broken = TTY::Table.new
broken << ["team1",1,2,"team2"]
broken << ["team3",0,1,"team4"]

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

            ┌─────┬─┬─┬─────┐
            │Home │H│A│Away │
            ├─────┼─┼─┼─────┤
            │team1│1│2│team2│
            │team3│0│1│team4│
            └─────┴─┴─┴─────┘
┌─────┬─┬─┬─────┐
            │team1│1│2│team2│
            │team3│0│1│team4│
            └─────┴─┴─┴─────┘

Requirements

  • [X] Tests written & passing locally?
  • [X] Code style checked?
  • [ ] Rebased with master branch?
  • [X] Documentation updated?
  • [X] Changelog updated?

rogermarlow avatar Mar 14 '24 09:03 rogermarlow

This has failed at appveyor because of a github connectivity issue rather than a test failure. I don't know how to re-run the job so I will push a trivial change.

rogermarlow avatar Mar 15 '24 14:03 rogermarlow