@@ -34,19 +34,18 @@ fun HighlightedText(
3434) {
3535 if (pattern.isEmpty()) {
3636 Text (
37- text = text, // Explicitly naming arguments for clarity
37+ text = text,
3838 maxLines = maxLines,
39- overflow = TextOverflow .Ellipsis
39+ overflow = TextOverflow .Ellipsis ,
4040 )
4141 } else if (text.equals(pattern, ignoreCase = true )) {
42- // Fallback for full-text match to avoid potential crash
4342 Text (
4443 text = text,
4544 maxLines = maxLines,
46- overflow = TextOverflow .Ellipsis
45+ overflow = TextOverflow .Ellipsis ,
46+ color = MaterialTheme .colors.primary,
4747 )
4848 } else {
49- // Original compact highlighting logic for partial matches
5049 val highlightColor = MaterialTheme .colors.primary
5150 val annotatedString = remember(text, pattern, highlightColor) {
5251 buildAnnotatedString {
@@ -55,7 +54,7 @@ fun HighlightedText(
5554 append(s)
5655 if (index != splitText.size - 1 ) {
5756 withStyle(style = SpanStyle (color = highlightColor)) {
58- append(pattern) // Appends the pattern string directly
57+ append(pattern)
5958 }
6059 }
6160 }
@@ -64,7 +63,7 @@ fun HighlightedText(
6463 Text (
6564 text = annotatedString,
6665 maxLines = maxLines,
67- overflow = TextOverflow .Ellipsis
66+ overflow = TextOverflow .Ellipsis ,
6867 )
6968 }
7069}
@@ -75,7 +74,7 @@ fun HighlightedTextPreview() {
7574 LinuxTheme {
7675 HighlightedText (
7776 text = " pacman" ,
78- pattern = " cm"
77+ pattern = " cm" ,
7978 )
8079 }
8180}
0 commit comments