From 506dfe5fea8dbe6d2e84b365388c7a7e26d43b77 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Mon, 11 Oct 2021 11:46:37 +0300 Subject: [PATCH] Adding trailing space " " or ": " if the user started a sentence by mentioning someone, --- .../app/features/home/room/detail/AutoCompleter.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt index d4430730d7..1fcac59b00 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/AutoCompleter.kt @@ -220,8 +220,16 @@ class AutoCompleter @AssistedInject constructor( // Replace the word by its completion val displayName = matrixItem.getBestName() - // with a trailing space - editable.replace(startIndex, endIndex, "$displayName ") + + // Adding trailing space " " or ": " if the user started mention someone + val displayNameSuffix = + if (firstChar == "@" && editText.length() == 1) { + ": " + } else { + " " + } + + editable.replace(startIndex, endIndex, "$displayName$displayNameSuffix") // Add the span val span = PillImageSpan(