Skip to content

Commit

Permalink
chore: make copy() do something
Browse files Browse the repository at this point in the history
  • Loading branch information
leg100 committed Jul 23, 2024
1 parent dd6b918 commit e90bd2b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/tui/table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e90bd2b

Please sign in to comment.