mirror of
https://github.com/mum4k/termdash.git
synced 2025-05-08 19:29:25 +08:00
BugFix: getWrapMode called before hierarchical options had links to parents.
This commit is contained in:
parent
bfbdede5a8
commit
609a731487
@ -283,6 +283,7 @@ func (c *Content) addRow(row *Row) error {
|
||||
row.hierarchical.parent = c.opts.hierarchical
|
||||
for _, tableCell := range row.cells {
|
||||
tableCell.hierarchical.parent = row.hierarchical
|
||||
tableCell.trimmable = tableCell.hierarchical.getWrapMode() == wrap.Never
|
||||
for _, tableData := range tableCell.data {
|
||||
for _, dataCell := range tableData.cells {
|
||||
if !dataCell.Opts.IsDefault() {
|
||||
|
@ -187,9 +187,6 @@ func NewCellWithOpts(data []*Data, opts ...CellOption) *Cell {
|
||||
for _, opt := range opts {
|
||||
opt.set(c)
|
||||
}
|
||||
|
||||
// We trim when we don't wrap.
|
||||
c.trimmable = c.hierarchical.getWrapMode() == wrap.Never
|
||||
return c
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ func TestColumnWidths(t *testing.T) {
|
||||
want: []columnWidth{1, 3},
|
||||
},
|
||||
{
|
||||
desc: "cells that wrap aren't accounted for",
|
||||
desc: "cells that wrap aren't accounted for, wrap configured at cell level",
|
||||
columns: Columns(2),
|
||||
rows: []*Row{
|
||||
NewRow(
|
||||
@ -203,6 +203,29 @@ func TestColumnWidths(t *testing.T) {
|
||||
cvsWidth: 4,
|
||||
want: []columnWidth{2, 2},
|
||||
},
|
||||
{
|
||||
desc: "cells that wrap aren't accounted for, wrap configured at content level",
|
||||
columns: Columns(2),
|
||||
rows: []*Row{
|
||||
NewRow(
|
||||
NewCell("ab"),
|
||||
NewCell("cde"),
|
||||
),
|
||||
NewRow(
|
||||
NewCell("a"),
|
||||
NewCell("cde"),
|
||||
),
|
||||
NewRow(
|
||||
NewCell(""),
|
||||
NewCell("cde"),
|
||||
),
|
||||
},
|
||||
opts: []ContentOption{
|
||||
WrapAtWords(),
|
||||
},
|
||||
cvsWidth: 4,
|
||||
want: []columnWidth{2, 2},
|
||||
},
|
||||
{
|
||||
desc: "two columns, canvas not wide enough, optimal to trim second",
|
||||
columns: Columns(2),
|
||||
|
Loading…
x
Reference in New Issue
Block a user