mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-14 22:33:47 -05:00
Make 'current-fg' inherit from 'fg' to simplify configuration
If you do not want 'current-fg' to inherit attributes of 'fg', prefix it with 'regular:' to reset them. # italic and underline fzf --color fg:italic,current-fg:underline # only underline fzf --color fg:italic,current-fg:regular:underline
This commit is contained in:
@@ -2725,38 +2725,38 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
|
||||
sort.Sort(ByOrder(charOffsets))
|
||||
}
|
||||
|
||||
wholeCovered := len(t.nthCurrent) == 0
|
||||
for _, nth := range t.nthCurrent {
|
||||
// Do we still want to apply a different style when the current nth
|
||||
// covers the whole string? Probably not. And we can simplify the logic.
|
||||
if nth.IsFull() {
|
||||
wholeCovered = true
|
||||
break
|
||||
// When postTask is nil, we're printing header lines. No need to care about nth.
|
||||
var nthOffsets []Offset
|
||||
if postTask != nil {
|
||||
wholeCovered := len(t.nthCurrent) == 0
|
||||
for _, nth := range t.nthCurrent {
|
||||
// Do we still want to apply a different style when the current nth
|
||||
// covers the whole string? Probably not. And we can simplify the logic.
|
||||
if nth.IsFull() {
|
||||
wholeCovered = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
// But if 'nth' is set to 'regular', it's a sign that you're applying
|
||||
// a different style to the rest of the string. e.g. 'nth:regular,fg:dim'
|
||||
// In this case, we still need to apply and clear the style.
|
||||
// We do the same when postTask is nil, which means we're printing header lines.
|
||||
if t.nthAttr == tui.AttrRegular && wholeCovered || postTask == nil {
|
||||
if t.nthAttr == tui.AttrRegular {
|
||||
if wholeCovered && t.nthAttr&tui.AttrRegular > 0 {
|
||||
// But if 'nth' is set to 'regular', it's a sign that you're applying
|
||||
// a different style to the rest of the string. e.g. 'nth:regular,fg:dim'
|
||||
// In this case, we still need to apply it to clear the style.
|
||||
colBase = colBase.WithAttr(t.nthAttr)
|
||||
}
|
||||
}
|
||||
var nthOffsets []Offset
|
||||
if !wholeCovered && t.nthAttr > 0 && postTask != nil {
|
||||
var tokens []Token
|
||||
if item.transformed != nil {
|
||||
tokens = item.transformed.tokens
|
||||
} else {
|
||||
tokens = Transform(Tokenize(item.text.ToString(), t.delimiter), t.nthCurrent)
|
||||
if !wholeCovered && t.nthAttr > 0 {
|
||||
var tokens []Token
|
||||
if item.transformed != nil {
|
||||
tokens = item.transformed.tokens
|
||||
} else {
|
||||
tokens = Transform(Tokenize(item.text.ToString(), t.delimiter), t.nthCurrent)
|
||||
}
|
||||
for _, token := range tokens {
|
||||
start := token.prefixLength
|
||||
end := start + int32(token.text.Length())
|
||||
nthOffsets = append(nthOffsets, Offset{int32(start), int32(end)})
|
||||
}
|
||||
sort.Sort(ByOrder(nthOffsets))
|
||||
}
|
||||
for _, token := range tokens {
|
||||
start := token.prefixLength
|
||||
end := start + int32(token.text.Length())
|
||||
nthOffsets = append(nthOffsets, Offset{int32(start), int32(end)})
|
||||
}
|
||||
sort.Sort(ByOrder(nthOffsets))
|
||||
}
|
||||
allOffsets := result.colorOffsets(charOffsets, nthOffsets, t.theme, colBase, colMatch, t.nthAttr, current)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user