Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/thor/shell/table_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def print_border_separator
def truncate(string)
return string unless @truncate
chars = string.chars.to_a
if chars.length <= @truncate
if chars.length <= @truncate - @indent
chars.join
else
chars[0, @truncate - 3 - @indent].join + "..."
Expand Down
7 changes: 7 additions & 0 deletions spec/shell/basic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,13 @@ def #456 Lanç...
TABLE
end

it "includes the indentation when checking the maximum terminal width" do
content = capture(:stdout) { shell.print_table([["abc", "#123", "first thr"]], indent: 2, truncate: 20) }
expect(content).to eq(<<-TABLE)
abc #123 firs...
TABLE
end

it "honors the colwidth option" do
content = capture(:stdout) { shell.print_table(@table, colwidth: 10) }
expect(content).to eq(<<-TABLE)
Expand Down
Loading