You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
funcTestSizing(t*testing.T) {
t.Run("margin and padding with fixed width", func(t*testing.T) {
want:=7table:=New().
Border(lipgloss.NormalBorder()).
StyleFunc(func(row, colint) lipgloss.Style {
switch {
caserow==HeaderRow:
returnlipgloss.NewStyle().Align(lipgloss.Center)
default:
returnlipgloss.NewStyle().
Padding(1).
Margin(1).
Align(lipgloss.Right).
Background(lipgloss.Color("#874bfc"))
}
}).
Headers("LANGUAGE", "FORMAL", "INFORMAL").
Row("Chinese", "Nǐn hǎo", "Nǐ hǎo").
Row("French", "Bonjour", "Salut").
Row("Japanese", "こんにちは", "やあ").
Row("Russian", "Zdravstvuyte", "Privet").
Row("Spanish", "Hola", "¿Qué tal?").
Width(50).
Height(want)
// TODO make this test pass. computeHeight doesn't account for margin// and padding, so we get an unexpected actual table height.got:=table.String()
iflipgloss.Height(got) !=want {
t.Fatalf("got an unexpected table height. Should be %d\n%s", want, got)
}
})
}
When we set Height, that should be the total height of the table including borders, text, and whitespace. We need to account for that in the render. The value of the height is the number of cells tall the table should be
The text was updated successfully, but these errors were encountered:
Describe the bug
If we set a height for the table, it leads to unexpected results when margins and padding are set.
To Reproduce
Steps to reproduce the behavior: there is a failing test on https://github.com/charmbracelet/lipgloss/tree/fix-compute-height
This is the test:
When we set
Height
, that should be the total height of the table including borders, text, and whitespace. We need to account for that in the render. The value of the height is the number of cells tall the table should beThe text was updated successfully, but these errors were encountered: