MCPcopy Create free account
hub / github.com/driangle/taskmd / highlightMatch

Function highlightMatch

apps/cli/internal/cli/search.go:133–148  ·  view source on GitHub ↗
(text, query string, r *lipgloss.Renderer)

Source from the content-addressed store, hash-verified

131}
132
133func highlightMatch(text, query string, r *lipgloss.Renderer) string {
134 lowerText := strings.ToLower(text)
135 lowerQuery := strings.ToLower(query)
136
137 idx := strings.Index(lowerText, lowerQuery)
138 if idx < 0 {
139 return text
140 }
141
142 style := r.NewStyle().Foreground(lipgloss.Color("3")).Bold(true) // Yellow bold
143 before := text[:idx]
144 match := text[idx : idx+len(query)]
145 after := text[idx+len(query):]
146
147 return before + style.Render(match) + after
148}

Callers 2

outputSearchTableFunction · 0.85
TestHighlightMatchFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestHighlightMatchFunction · 0.68