Fixed list selected style not being applied in a desirable way when reverse attribute is part of the style

Make code more optimized

Undo extra changes not necessary to solving the problem
pull/955/head
Souheab 3 months ago
parent e2bf3e8a15
commit 5eebffbce4

@ -525,9 +525,10 @@ func (l *List) Draw(screen tcell.Screen) {
// Background color of selected text.
if index == l.currentItem && (!l.selectedFocusOnly || l.HasFocus()) {
textWidth := width
taggedStringWidth := TaggedStringWidth(item.MainText)
if !l.highlightFullLine {
if w := TaggedStringWidth(item.MainText); w < textWidth {
textWidth = w
if taggedStringWidth < textWidth {
textWidth = taggedStringWidth
}
}
@ -536,7 +537,7 @@ func (l *List) Draw(screen tcell.Screen) {
m, c, style, _ := screen.GetContent(x+bx, y)
fg, _, _ := style.Decompose()
style = l.selectedStyle
if fg != mainTextColor {
if bx < taggedStringWidth && fg != mainTextColor {
style = style.Foreground(fg)
}
screen.SetContent(x+bx, y, m, c, style)

Loading…
Cancel
Save