From d760238dd2e9cefae6e49ce1f10dad5c8f2a9241 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Fri, 15 Mar 2024 10:56:32 -0400 Subject: [PATCH] fix(style): possible nil panic (#245) --- style.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/style.go b/style.go index 58dcc0f..6efbc3b 100644 --- a/style.go +++ b/style.go @@ -402,7 +402,10 @@ func (s Style) Render(strs ...string) string { // Truncate according to MaxHeight if maxHeight > 0 { lines := strings.Split(str, "\n") - str = strings.Join(lines[:min(maxHeight, len(lines))], "\n") + height := min(maxHeight, len(lines)) + if len(lines) > 0 { + str = strings.Join(lines[:height], "\n") + } } if transform != nil {