Skip to content

Commit

Permalink
fix(table): append headers/columns to zero sized string slice
Browse files Browse the repository at this point in the history
  • Loading branch information
buztard authored and maaslalani committed Sep 2, 2022
1 parent 278edd1 commit 13f52d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "…"))
Expand All @@ -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, "…")))
Expand Down

0 comments on commit 13f52d6

Please sign in to comment.