Skip to content

Commit

Permalink
Conditionally highlight wrapped lines
Browse files Browse the repository at this point in the history
  • Loading branch information
robinovitch61 committed Jul 4, 2022
1 parent 054be73 commit e84244e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/tui/components/viewport/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,13 @@ func (m Model) View() string {
visibleLines := m.getVisibleLines()
hasNoHighlight := runeCount(m.stringToHighlight) == 0
for idx, line := range visibleLines {
isSelected := m.selectionEnabled && m.getContentIdx(m.yOffset+idx) == m.selectedContentIdx
contentIdx := m.getContentIdx(m.yOffset + idx)
isSelected := m.selectionEnabled && contentIdx == m.selectedContentIdx

lineStyle := m.ContentStyle
for k, v := range m.ConditionalStyle {
if strings.Contains(line, k) {
entireLine := m.content[contentIdx]
if strings.Contains(entireLine, k) {
lineStyle = v
}
}
Expand Down

0 comments on commit e84244e

Please sign in to comment.