Fix completing in the middle of a name with spaces
This commit is contained in:
parent
bea1d60621
commit
6f37ce3519
|
@ -13,7 +13,8 @@ HListView {
|
||||||
property bool open: false
|
property bool open: false
|
||||||
|
|
||||||
property var originalWord: null
|
property var originalWord: null
|
||||||
property int replacementLength: -1
|
property int replacementStart: -1
|
||||||
|
property int replacementEnd: -1
|
||||||
property bool autoOpenCompleted: false
|
property bool autoOpenCompleted: false
|
||||||
property var usersCompleted: ({}) // {displayName: userId}
|
property var usersCompleted: ({}) // {displayName: userId}
|
||||||
|
|
||||||
|
@ -25,8 +26,6 @@ HListView {
|
||||||
|
|
||||||
readonly property var wordToComplete:
|
readonly property var wordToComplete:
|
||||||
open ? originalWord || textArea.getWordBehindCursor() : null
|
open ? originalWord || textArea.getWordBehindCursor() : null
|
||||||
// property var pr: wordToComplete
|
|
||||||
// onPrChanged: print(JSON.stringify( pr, null, 4))
|
|
||||||
|
|
||||||
readonly property string modelFilter:
|
readonly property string modelFilter:
|
||||||
autoOpen && wordToComplete ? wordToComplete.word.replace(/^@/, "") :
|
autoOpen && wordToComplete ? wordToComplete.word.replace(/^@/, "") :
|
||||||
|
@ -47,12 +46,10 @@ HListView {
|
||||||
const current = textArea.getWordBehindCursor()
|
const current = textArea.getWordBehindCursor()
|
||||||
if (! current) return
|
if (! current) return
|
||||||
|
|
||||||
const start =
|
replacementStart === -1 || replacementEnd === -1 ?
|
||||||
replacementLength === -1 ?
|
textArea.remove(current.start, current.end + 1) :
|
||||||
current.start :
|
textArea.remove(replacementStart, replacementEnd)
|
||||||
current.end + 1 - replacementLength
|
|
||||||
|
|
||||||
textArea.remove(start, current.end + 1)
|
|
||||||
textArea.insertAtCursor(withText)
|
textArea.insertAtCursor(withText)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +109,8 @@ HListView {
|
||||||
onAutoOpenChanged: open = autoOpen
|
onAutoOpenChanged: open = autoOpen
|
||||||
onOpenChanged: if (! open) {
|
onOpenChanged: if (! open) {
|
||||||
originalWord = null
|
originalWord = null
|
||||||
replacementLength = -1
|
replacementStart = -1
|
||||||
|
replacementEnd = -1
|
||||||
currentIndex = -1
|
currentIndex = -1
|
||||||
autoOpenCompleted = false
|
autoOpenCompleted = false
|
||||||
py.callCoro("set_string_filter", [model.modelId, ""])
|
py.callCoro("set_string_filter", [model.modelId, ""])
|
||||||
|
@ -132,7 +130,8 @@ HListView {
|
||||||
const replacement = member.display_name || member.id
|
const replacement = member.display_name || member.id
|
||||||
|
|
||||||
replaceCompletionOrCurrentWord(replacement)
|
replaceCompletionOrCurrentWord(replacement)
|
||||||
replacementLength = replacement.length
|
replacementStart = textArea.cursorPosition - replacement.length
|
||||||
|
replacementEnd = textArea.cursorPosition
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior on opacity { HNumberAnimation {} }
|
Behavior on opacity { HNumberAnimation {} }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user