klint
This commit is contained in:
parent
38b93c527b
commit
97766404d6
|
@ -24,8 +24,6 @@ import java.util.*
|
|||
*
|
||||
* For now only support UserMentionSpans (TODO rooms, room aliases, etc...)
|
||||
*/
|
||||
|
||||
|
||||
object TextPillsUtils {
|
||||
|
||||
private data class MentionLinkSpec(val span: UserMentionSpan, val start: Int, val end: Int)
|
||||
|
@ -34,7 +32,6 @@ object TextPillsUtils {
|
|||
|
||||
private const val MENTION_SPAN_TO_MD_TEMPLATE = "[%2\$s](https://matrix.to/#/%1\$s)"
|
||||
|
||||
|
||||
/**
|
||||
* Detects if transformable spans are present in the text.
|
||||
* @return the transformed String or null if no Span found
|
||||
|
@ -60,7 +57,7 @@ object TextPillsUtils {
|
|||
?.takeIf { it.isNotEmpty() }
|
||||
?: return null
|
||||
|
||||
//we need to prune overlaps!
|
||||
// we need to prune overlaps!
|
||||
pruneOverlaps(pills)
|
||||
|
||||
return buildString {
|
||||
|
@ -83,22 +80,20 @@ object TextPillsUtils {
|
|||
val b = links[i + 1]
|
||||
var remove = -1
|
||||
|
||||
//test if there is an overlap
|
||||
// test if there is an overlap
|
||||
if (b.start in a.start until a.end) {
|
||||
|
||||
when {
|
||||
b.end <= a.end ->
|
||||
//b is inside a -> b should be removed
|
||||
// b is inside a -> b should be removed
|
||||
remove = i + 1
|
||||
a.end - a.start > b.end - b.start ->
|
||||
//overlap and a is bigger -> b should be removed
|
||||
// overlap and a is bigger -> b should be removed
|
||||
remove = i + 1
|
||||
a.end - a.start < b.end - b.start ->
|
||||
//overlap and a is smaller -> a should be removed
|
||||
// overlap and a is smaller -> a should be removed
|
||||
remove = i
|
||||
}
|
||||
|
||||
|
||||
if (remove != -1) {
|
||||
links.removeAt(remove)
|
||||
len--
|
||||
|
|
Loading…
Reference in New Issue