From e6750254114ea9c16a33212b98658040b5cc7b25 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 9 Aug 2024 14:50:24 +0200 Subject: [PATCH] Return nil columnPositions when not rendering anything ... instead of returning a slice with a single [0] element. This makes it easier to check whether we have columnPositions. --- pkg/utils/formatting.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/utils/formatting.go b/pkg/utils/formatting.go index b7817346a..b13a2ffa8 100644 --- a/pkg/utils/formatting.go +++ b/pkg/utils/formatting.go @@ -54,6 +54,10 @@ func WithPadding(str string, padding int, alignment Alignment) string { // returns a list of strings that should be joined with "\n", and an array of // the column positions func RenderDisplayStrings(displayStringsArr [][]string, columnAlignments []Alignment) ([]string, []int) { + if len(displayStringsArr) == 0 { + return []string{}, nil + } + displayStringsArr, columnAlignments, removedColumns := excludeBlankColumns(displayStringsArr, columnAlignments) padWidths := getPadWidths(displayStringsArr) columnConfigs := make([]ColumnConfig, len(padWidths))