fix: [re-add] The text entry box shouldn't highlight invalid @mentions
Fixes #4678 The text input in chat was highlighting whatever was starting with @. Fixed to highlight only valid user mentions.
This commit is contained in:
parent
7268ec3773
commit
3b43d2f9ea
|
@ -237,11 +237,19 @@ Rectangle {
|
||||||
|
|
||||||
isColonPressed = (event.key === Qt.Key_Colon) && (event.modifiers & Qt.ShiftModifier);
|
isColonPressed = (event.key === Qt.Key_Colon) && (event.modifiers & Qt.ShiftModifier);
|
||||||
|
|
||||||
if (event.key === Qt.Key_Space && suggestionsBox.formattedPlainTextFilter.length > 1 && suggestionsBox.formattedPlainTextFilter.trim().split(" ").length === 1) {
|
if (suggestionsBox.visible) {
|
||||||
let aliasName = suggestionsBox.formattedPlainTextFilter
|
let aliasName = suggestionsBox.formattedPlainTextFilter;
|
||||||
let lastCursorPosition = suggestionsBox.suggestionFilter.cursorPosition
|
let lastCursorPosition = suggestionsBox.suggestionFilter.cursorPosition;
|
||||||
let lastAtPosition = suggestionsBox.suggestionFilter.lastAtPosition
|
let lastAtPosition = suggestionsBox.suggestionFilter.lastAtPosition;
|
||||||
insertMention(aliasName, lastAtPosition, lastCursorPosition)
|
if (aliasName.toLowerCase() === suggestionsBox.suggestionsModel.get(suggestionsBox.listView.currentIndex).name.toLowerCase()
|
||||||
|
&& (event.key !== Qt.Key_Backspace) && (event.key !== Qt.Key_Delete)) {
|
||||||
|
insertMention(aliasName, lastAtPosition, lastCursorPosition);
|
||||||
|
} else if (event.key === Qt.Key_Space) {
|
||||||
|
var plainTextToReplace = messageInputField.getText(lastAtPosition, lastCursorPosition);
|
||||||
|
messageInputField.remove(lastAtPosition, lastCursorPosition);
|
||||||
|
messageInputField.insert(lastAtPosition, plainTextToReplace);
|
||||||
|
suggestionsBox.hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue