Skip to content

Commit

Permalink
fix: secure crash when end Index is higher than length
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas committed Sep 1, 2023
1 parent af949b1 commit 69fda14
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ fun HighlightName(
}

highlightIndexes
.forEach { highLightIndexes ->
addStyle(
style = SpanStyle(background = MaterialTheme.wireColorScheme.highLight.copy(alpha = 0.5f)),
start = highLightIndexes.startIndex,
end = highLightIndexes.endIndex
)
.forEach { highLightIndex ->
if (highLightIndex.endIndex < this.length) {
addStyle(
style = SpanStyle(background = MaterialTheme.wireColorScheme.highLight.copy(alpha = 0.5f)),
start = highLightIndex.startIndex,
end = highLightIndex.endIndex
)
}
}
},
maxLines = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ fun HighlightSubtitle(

highlightIndexes
.forEach { highLightIndex ->
addStyle(
style = SpanStyle(
background = MaterialTheme.wireColorScheme.highLight.copy(alpha = 0.5f),
),
start = highLightIndex.startIndex + suffix.length,
end = highLightIndex.endIndex + suffix.length
)
if (highLightIndex.endIndex < this.length) {
addStyle(
style = SpanStyle(
background = MaterialTheme.wireColorScheme.highLight.copy(alpha = 0.5f),
),
start = highLightIndex.startIndex + suffix.length,
end = highLightIndex.endIndex + suffix.length
)
}
}
},
maxLines = 1,
Expand Down

0 comments on commit 69fda14

Please sign in to comment.