Start completing with message starting with @

This commit is contained in:
Carl Schwan
2020-11-19 16:31:21 +00:00
parent e6ed67b1a2
commit 3a7565874e

View File

@@ -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) {