fix: markdown rendering crash

Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
Infi 2024-06-05 15:51:31 +02:00
parent 3127b95d9e
commit 7894364d84
1 changed files with 20 additions and 4 deletions

View File

@ -83,7 +83,11 @@ fun annotateText(node: AstNode): AnnotatedString {
var lastIndex = 0
for (mention in mentions) {
append(text.substring(lastIndex, mention.range.first))
try {
append(text.substring(lastIndex, mention.range.first))
} catch (e: Exception) {
// no-op
}
pushStringAnnotation(
tag = Annotations.UserMention.tag,
annotation = mention.groupValues[1]
@ -108,7 +112,11 @@ fun annotateText(node: AstNode): AnnotatedString {
}
for (channel in channels) {
append(text.substring(lastIndex, channel.range.first))
try {
append(text.substring(lastIndex, channel.range.first))
} catch (e: Exception) {
// no-op
}
pushStringAnnotation(
tag = Annotations.ChannelMention.tag,
annotation = channel.groupValues[1]
@ -130,7 +138,11 @@ fun annotateText(node: AstNode): AnnotatedString {
}
for (emote in customEmotes) {
append(text.substring(lastIndex, emote.range.first))
try {
append(text.substring(lastIndex, emote.range.first))
} catch (e: Exception) {
// no-op
}
pushStringAnnotation(
tag = Annotations.CustomEmote.tag,
annotation = emote.groupValues[1]
@ -141,7 +153,11 @@ fun annotateText(node: AstNode): AnnotatedString {
}
for (timestamp in timestamps) {
append(text.substring(lastIndex, timestamp.range.first))
try {
append(text.substring(lastIndex, timestamp.range.first))
} catch (e: Exception) {
// no-op
}
pushStringAnnotation(
tag = Annotations.Timestamp.tag,
annotation = timestamp.groupValues[1]