mirror of
https://github.com/charmbracelet/gum
synced 2024-06-26 09:10:09 +02:00
make highlight respect user settings
This commit is contained in:
parent
ea772d6677
commit
c4e45e4e00
|
@ -72,12 +72,13 @@ func (s *search) NextMatch(m *model) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leftPad, rightPad := utils.LipglossPadding(m.matchStyle)
|
||||||
s.matchIndex = (s.matchIndex + 1) % len(allMatches)
|
s.matchIndex = (s.matchIndex + 1) % len(allMatches)
|
||||||
match := allMatches[s.matchIndex]
|
match := allMatches[s.matchIndex]
|
||||||
lhs := m.content[:match[0]]
|
lhs := m.content[:match[0]]
|
||||||
rhs := m.content[match[0]:]
|
rhs := m.content[match[0]:]
|
||||||
s.matchString = m.content[match[0]:match[1]]
|
s.matchString = m.content[match[0]:match[1]]
|
||||||
s.matchLipglossStr = m.matchHighlightStyle.Render(s.matchString)
|
s.matchLipglossStr = m.matchHighlightStyle.Render(s.matchString[leftPad : len(s.matchString)-(len(s.matchString)-leftPad-rightPad)])
|
||||||
m.content = lhs + strings.Replace(rhs, m.content[match[0]:match[1]], s.matchLipglossStr, 1)
|
m.content = lhs + strings.Replace(rhs, m.content[match[0]:match[1]], s.matchLipglossStr, 1)
|
||||||
|
|
||||||
// Update the viewport position.
|
// Update the viewport position.
|
||||||
|
@ -117,11 +118,12 @@ func (s *search) PrevMatch(m *model) {
|
||||||
s.matchIndex = 0
|
s.matchIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leftPad, rightPad := utils.LipglossPadding(m.matchStyle)
|
||||||
match := allMatches[s.matchIndex]
|
match := allMatches[s.matchIndex]
|
||||||
lhs := m.content[:match[0]]
|
lhs := m.content[:match[0]]
|
||||||
rhs := m.content[match[0]:]
|
rhs := m.content[match[0]:]
|
||||||
s.matchString = m.content[match[0]:match[1]]
|
s.matchString = m.content[match[0]:match[1]]
|
||||||
s.matchLipglossStr = m.matchHighlightStyle.Render(s.matchString)
|
s.matchLipglossStr = m.matchHighlightStyle.Render(s.matchString[leftPad : len(s.matchString)-(len(s.matchString)-leftPad-rightPad)])
|
||||||
m.content = lhs + strings.Replace(rhs, m.content[match[0]:match[1]], s.matchLipglossStr, 1)
|
m.content = lhs + strings.Replace(rhs, m.content[match[0]:match[1]], s.matchLipglossStr, 1)
|
||||||
|
|
||||||
// Update the viewport position.
|
// Update the viewport position.
|
||||||
|
|
Loading…
Reference in a new issue