Skip to content

Commit

Permalink
refactor: simplify condition for non-empty help view
Browse files Browse the repository at this point in the history
  • Loading branch information
ardnew committed May 2, 2024
1 parent 74ce87f commit 53f853d
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package huh

import (
"strings"
"unicode"

"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/paginator"
Expand Down Expand Up @@ -317,13 +316,10 @@ func (g *Group) View() string {
foot.WriteString(g.theme.Focused.ErrorMessage.Render(err.Error()))
}
}
if foot.Len() > 0 && hasNonSpace(foot.String()) {
if strings.TrimSpace(foot.String()) != "" {
view.Grow(foot.Len() + 1) // +1 for newline/gap
view.WriteRune('\n')
view.WriteString(foot.String())
}
return view.String()
}

func isNonSpace(r rune) bool { return !unicode.IsSpace(r) }
func hasNonSpace(s string) bool { return strings.IndexFunc(s, isNonSpace) != -1 }

0 comments on commit 53f853d

Please sign in to comment.