fix(table): append headers/columns to zero sized string slice

This commit is contained in:
Bastian Winkler 2022-08-21 13:34:50 +02:00 committed by Maas Lalani
parent 278edd1c2b
commit 13f52d678d

View File

@ -346,7 +346,7 @@ func (m *Model) FromValues(value, separator string) {
}
func (m Model) headersView() string {
var s = make([]string, len(m.cols))
var s = make([]string, 0, len(m.cols))
for _, col := range m.cols {
style := lipgloss.NewStyle().Width(col.Width).MaxWidth(col.Width).Inline(true)
renderedCell := style.Render(runewidth.Truncate(col.Title, col.Width, "…"))
@ -356,7 +356,7 @@ func (m Model) headersView() string {
}
func (m *Model) renderRow(rowID int) string {
var s = make([]string, len(m.cols))
var s = make([]string, 0, len(m.cols))
for i, value := range m.rows[rowID] {
style := lipgloss.NewStyle().Width(m.cols[i].Width).MaxWidth(m.cols[i].Width).Inline(true)
renderedCell := m.styles.Cell.Render(style.Render(runewidth.Truncate(value, m.cols[i].Width, "…")))