Fix autocompletion for users without display name

This commit is contained in:
miruka 2020-08-21 10:46:18 -04:00
parent cd81c94ce8
commit bea1d60621

View File

@ -128,9 +128,11 @@ HListView {
if (! originalWord) originalWord = textArea.getWordBehindCursor() if (! originalWord) originalWord = textArea.getWordBehindCursor()
if (autoOpen) autoOpenCompleted = true if (autoOpen) autoOpenCompleted = true
const name = model.get(currentIndex).display_name const member = model.get(currentIndex)
replaceCompletionOrCurrentWord(name) const replacement = member.display_name || member.id
replacementLength = name.length
replaceCompletionOrCurrentWord(replacement)
replacementLength = replacement.length
} }
Behavior on opacity { HNumberAnimation {} } Behavior on opacity { HNumberAnimation {} }
@ -150,11 +152,13 @@ HListView {
const pos = root.textArea.cursorPosition const pos = root.textArea.cursorPosition
const start = root.wordToComplete.start const start = root.wordToComplete.start
const end = let end = root.wordToComplete.end + 1
currentIndex === -1 ?
root.wordToComplete.end + 1 : if (currentIndex !== -1) {
root.wordToComplete.start + const member = model.get(currentIndex)
model.get(currentIndex).display_name.length const repl = member.display_name || member.id
end = root.wordToComplete.start + repl.length
}
if (pos < start || pos > end) root.accept() if (pos < start || pos > end) root.accept()
} }