Skip to content

Commit 3044146

Browse files
authored
fix: add missing underlineColorKey case in getAsColor (#624)
1 parent 1dd352c commit 3044146

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

get.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ func (s Style) getAsColor(k propKey) color.Color {
550550
c = s.borderBottomBgColor
551551
case borderLeftBackgroundKey:
552552
c = s.borderLeftBgColor
553+
case underlineColorKey:
554+
c = s.ulColor
553555
}
554556

555557
if c != nil {

style_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ func TestUnderline(t *testing.T) {
3434
NewStyle().UnderlineStyle(UnderlineCurly),
3535
"\x1b[4;4:3ma\x1b[m\x1b[4;4:3mb\x1b[m\x1b[4m \x1b[m\x1b[4;4:3mc\x1b[m",
3636
},
37+
{
38+
NewStyle().UnderlineStyle(UnderlineCurly).UnderlineColor(Color("#FF0000")),
39+
"\x1b[4;58;2;255;0;0;4:3ma\x1b[m\x1b[4;58;2;255;0;0;4:3mb\x1b[m\x1b[58;2;255;0;0;4m \x1b[m\x1b[4;58;2;255;0;0;4:3mc\x1b[m",
40+
},
3741
}
3842

3943
for i, tc := range tt {
@@ -47,6 +51,16 @@ func TestUnderline(t *testing.T) {
4751
}
4852
}
4953

54+
func TestGetUnderlineColor(t *testing.T) {
55+
t.Parallel()
56+
57+
red := Color("#FF0000")
58+
s := NewStyle().Underline(true).UnderlineColor(red)
59+
if s.GetUnderlineColor() != red {
60+
t.Errorf("GetUnderlineColor() = %v, want %v", s.GetUnderlineColor(), red)
61+
}
62+
}
63+
5064
func TestStrikethrough(t *testing.T) {
5165
t.Parallel()
5266

0 commit comments

Comments
 (0)