Skip to content

Commit 13f52d6

Browse files
buztardmaaslalani
authored andcommitted
fix(table): append headers/columns to zero sized string slice
1 parent 278edd1 commit 13f52d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

table/table.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func (m *Model) FromValues(value, separator string) {
346346
}
347347

348348
func (m Model) headersView() string {
349-
var s = make([]string, len(m.cols))
349+
var s = make([]string, 0, len(m.cols))
350350
for _, col := range m.cols {
351351
style := lipgloss.NewStyle().Width(col.Width).MaxWidth(col.Width).Inline(true)
352352
renderedCell := style.Render(runewidth.Truncate(col.Title, col.Width, "…"))
@@ -356,7 +356,7 @@ func (m Model) headersView() string {
356356
}
357357

358358
func (m *Model) renderRow(rowID int) string {
359-
var s = make([]string, len(m.cols))
359+
var s = make([]string, 0, len(m.cols))
360360
for i, value := range m.rows[rowID] {
361361
style := lipgloss.NewStyle().Width(m.cols[i].Width).MaxWidth(m.cols[i].Width).Inline(true)
362362
renderedCell := m.styles.Cell.Render(style.Render(runewidth.Truncate(value, m.cols[i].Width, "…")))

0 commit comments

Comments
 (0)