fix(style): possible nil panic (#245)

This commit is contained in:
Maas Lalani 2024-03-15 10:56:32 -04:00 committed by GitHub
parent 96795629c1
commit d760238dd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -402,7 +402,10 @@ func (s Style) Render(strs ...string) string {
// Truncate according to MaxHeight // Truncate according to MaxHeight
if maxHeight > 0 { if maxHeight > 0 {
lines := strings.Split(str, "\n") 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 { if transform != nil {