From 5f1864a3d32f1e6b2da23c4bdaae9f8b283e2ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Mon, 2 Sep 2024 14:36:28 +0200 Subject: [PATCH] Minor changes --- .../kotlin/com/pubnub/chat/internal/MessageDraftImpl.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/MessageDraftImpl.kt b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/MessageDraftImpl.kt index ec0cb8c3..7a05caba 100644 --- a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/MessageDraftImpl.kt +++ b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/MessageDraftImpl.kt @@ -45,7 +45,7 @@ class MessageDraftImpl( // clean up mentions that no longer start with a @ or #, or are empty strings mentions.removeIf { mention -> - if (mention.length == 0) { + if (mention.length == 0 + (mention.startChar?.let { 1 } ?: 0)) { true } else { when (mention) { @@ -141,7 +141,7 @@ class MessageDraftImpl( messageText.delete(offset, offset + length) mentions.forEach { mention -> val removalEnd = offset + length - if (!(offset > mention.endExclusive || removalEnd < mention.start)) { + if (offset <= mention.endExclusive && removalEnd >= mention.start) { val intersectStart = max(offset, mention.start) val intersectEnd = min(removalEnd, mention.endExclusive) val intersectLen = intersectEnd - intersectStart