From e90bd2b11e285b721c613ea9f1e67903e297f280 Mon Sep 17 00:00:00 2001 From: Louis Garman Date: Tue, 23 Jul 2024 10:50:23 +0100 Subject: [PATCH] chore: make copy() do something --- internal/tui/table/table.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/tui/table/table.go b/internal/tui/table/table.go index baa52634..26274b27 100644 --- a/internal/tui/table/table.go +++ b/internal/tui/table/table.go @@ -110,14 +110,13 @@ func New[V resource.Resource](cols []Column, fn RowRenderer[V], width, height in } // Copy column structs onto receiver, because the caller may modify columns. + m.cols = make([]Column, len(cols)) copy(m.cols, cols) - // For each column, set default truncation function if unset. - for _, col := range cols { + for i, col := range m.cols { if col.TruncationFunc == nil { - col.TruncationFunc = defaultTruncationFunc + m.cols[i].TruncationFunc = defaultTruncationFunc } - m.cols = append(m.cols, col) } m.setDimensions(width, height)