From 3a7565874ea95ae466badd7f29c01238be65c5f0 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Thu, 19 Nov 2020 16:31:21 +0000 Subject: [PATCH] Start completing with message starting with @ --- imports/NeoChat/Component/ChatTextInput.qml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/imports/NeoChat/Component/ChatTextInput.qml b/imports/NeoChat/Component/ChatTextInput.qml index 147c30bf2..8c21e07c5 100644 --- a/imports/NeoChat/Component/ChatTextInput.qml +++ b/imports/NeoChat/Component/ChatTextInput.qml @@ -306,6 +306,18 @@ ToolBar { isAutoCompleting = false autoCompleteListView.currentIndex = 0 } + + var autoCompletePrefix = text.substring(0, cursorPosition).split(" ").pop(); + if (!autoCompletePrefix) return + + if (autoCompletePrefix.startsWith("@")) { + autoCompletePrefix = autoCompletePrefix.substring(1); + autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1 // 1 = space + autoCompleteModel = currentRoom.getUsers(autoCompletePrefix) + if (autoCompleteModel.length === 0) return + isAutoCompleting = true + autoCompleteEndPosition = cursorPosition + } } function replaceAutoComplete(word) {