Fix mentioning blank display names

If the display name of a user is blank (e.g. just a space character),
autocomplete it as a user ID.

If the display name starts or ends with whitespace, trim it.
This commit is contained in:
miruka 2020-08-23 09:46:26 -04:00
parent fbf6e48b5b
commit fc6827807c
2 changed files with 3 additions and 4 deletions

View File

@ -1,6 +1,5 @@
# TODO
- save usersCompleted in state.json
- refresh server list button
- global presence control

View File

@ -70,7 +70,7 @@ HListView {
function accept() {
if (currentIndex !== -1) {
const member = model.get(currentIndex)
usersCompleted[member.id] = member.display_name
usersCompleted[member.id] = member.display_name.trim()
usersCompletedChanged()
}
@ -126,7 +126,7 @@ HListView {
if (autoOpen) autoOpenCompleted = true
const member = model.get(currentIndex)
const replacement = member.display_name || member.id
const replacement = member.display_name.trim() || member.id
replaceCompletionOrCurrentWord(replacement)
replacementStart = textArea.cursorPosition - replacement.length
@ -154,7 +154,7 @@ HListView {
if (root.currentIndex !== -1) {
const member = root.model.get(root.currentIndex)
const repl = member.display_name || member.id
const repl = member.display_name.trim() || member.id
end = root.wordToComplete.start + repl.length
}