mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
Merge pull request #2483 from stefanhaller/fix-setting-selectedLineBgColor
This commit is contained in:
commit
648748781d
2 changed files with 59 additions and 2 deletions
|
@ -30,9 +30,9 @@ func GetTextStyle(keys []string, background bool) style.TextStyle {
|
|||
} else if utils.IsValidHexValue(key) {
|
||||
c := style.NewRGBColor(color.HEX(key, background))
|
||||
if background {
|
||||
s.SetBg(c)
|
||||
s = s.SetBg(c)
|
||||
} else {
|
||||
s.SetFg(c)
|
||||
s = s.SetFg(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
57
pkg/theme/style_test.go
Normal file
57
pkg/theme/style_test.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
package theme
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/gookit/color"
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||
)
|
||||
|
||||
func TestGetTextStyle(t *testing.T) {
|
||||
scenarios := []struct {
|
||||
name string
|
||||
keys []string
|
||||
background bool
|
||||
expected style.TextStyle
|
||||
}{
|
||||
{
|
||||
name: "empty",
|
||||
keys: []string{""},
|
||||
background: true,
|
||||
expected: style.New(),
|
||||
},
|
||||
{
|
||||
name: "named color, fg",
|
||||
keys: []string{"blue"},
|
||||
background: false,
|
||||
expected: style.New().SetFg(style.NewBasicColor(color.FgBlue)),
|
||||
},
|
||||
{
|
||||
name: "named color, bg",
|
||||
keys: []string{"blue"},
|
||||
background: true,
|
||||
expected: style.New().SetBg(style.NewBasicColor(color.BgBlue)),
|
||||
},
|
||||
{
|
||||
name: "hex color, fg",
|
||||
keys: []string{"#123456"},
|
||||
background: false,
|
||||
expected: style.New().SetFg(style.NewRGBColor(color.RGBColor{0x12, 0x34, 0x56, 0})),
|
||||
},
|
||||
{
|
||||
name: "hex color, bg",
|
||||
keys: []string{"#abcdef"},
|
||||
background: true,
|
||||
expected: style.New().SetBg(style.NewRGBColor(color.RGBColor{0xab, 0xcd, 0xef, 1})),
|
||||
},
|
||||
}
|
||||
|
||||
for _, scenario := range scenarios {
|
||||
t.Run(scenario.name, func(t *testing.T) {
|
||||
if actual := GetTextStyle(scenario.keys, scenario.background); !reflect.DeepEqual(actual, scenario.expected) {
|
||||
t.Errorf("GetTextStyle() = %v, expected %v", actual, scenario.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue