Skip to content

Commit

Permalink
fix: renderer nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Oct 14, 2022
1 parent 0da4b11 commit 110086d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion color_test.go
Expand Up @@ -157,6 +157,12 @@ func TestRGBA(t *testing.T) {
CompleteColor{TrueColor: "#FF0000", ANSI256: "231", ANSI: "12"},
0x0000FF,
},
{
termenv.TrueColor,
true,
CompleteColor{TrueColor: "", ANSI256: "231", ANSI: "12"},
0x000000,
},
// lipgloss.CompleteAdaptiveColor
// dark
{
Expand Down Expand Up @@ -221,7 +227,7 @@ func TestRGBA(t *testing.T) {
r.SetColorProfile(tc.profile)
r.SetHasDarkBackground(tc.darkBg)

r, g, b, _ := termenv.ConvertToRGB(tc.input.color(r)).RGBA()
r, g, b, _ := tc.input.RGBA()
o := uint(r/256)<<16 + uint(g/256)<<8 + uint(b/256)

if o != tc.expected {
Expand Down
3 changes: 3 additions & 0 deletions style.go
Expand Up @@ -161,6 +161,9 @@ func (s Style) Inherit(i Style) Style {

// Render applies the defined style formatting to a given string.
func (s Style) Render(strs ...string) string {
if s.r == nil {
s.r = DefaultRenderer()
}
if s.value != "" {
strs = append([]string{s.value}, strs...)
}
Expand Down

0 comments on commit 110086d

Please sign in to comment.