Fix @autocomplete closing after one character

Typing e.g. "@a" would work, but "@ab" would always instantly close
the autocompletion UI if the cursor was at the end of the text area.
This commit is contained in:
miruka 2020-08-22 01:20:55 -04:00
parent 65f1cfe0c5
commit bc3d6d902f

View File

@ -159,12 +159,13 @@ HListView {
const start = root.wordToComplete.start const start = root.wordToComplete.start
let end = root.wordToComplete.end + 1 let end = root.wordToComplete.end + 1
if (currentIndex !== -1) { if (root.currentIndex !== -1) {
const member = model.get(currentIndex) const member = root.model.get(root.currentIndex)
const repl = member.display_name || member.id const repl = member.display_name || member.id
end = root.wordToComplete.start + repl.length end = root.wordToComplete.start + repl.length
} }
if (pos === root.textArea.length) return
if (pos < start || pos > end) root.accept() if (pos < start || pos > end) root.accept()
} }