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

Wrong table header width when using TTY::Link

Open MatheusRich opened this issue 3 years ago • 0 comments

Describe the problem

When tables contain a TTY::Link, the right margin is off. It seems that header width accounts for the text size when links are not supported (which is larger).

Steps to reproduce the problem

require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "tty-table"
  gem "tty-link"
end

require "tty-table"
require "tty-link"

headers = ["header 1", "header 2"]
rows = [
  [TTY::Link.link_to("hello", "https://example.com"), "world"]
]

puts TTY::Table.new(headers, rows).render

Actual behaviour

Note that it fails with all rendering modes image

Expected behaviour

In this example, the "header 1" column should be narrower.

Describe your environment

  • OS version: macOS Big Sur 11.6
  • Ruby version: ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-darwin20]
  • TTY::Table version: 0.12.0
  • TTY::Link version: 0.1.1

MatheusRich avatar Jan 10 '22 15:01 MatheusRich