From 97766404d639d9dce42da317970301009b3a321f Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 20 Nov 2019 17:32:36 +0100 Subject: [PATCH] klint --- .../api/session/room/send/TextPillsUtils.kt | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/send/TextPillsUtils.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/send/TextPillsUtils.kt index 941861f2ed..936b1d18c2 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/send/TextPillsUtils.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/send/TextPillsUtils.kt @@ -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--