xP: abort autocomplete when no longer applicable
This commit is contained in:
parent
2b13f891c9
commit
2e3005d88b
|
@ -421,16 +421,28 @@ let BufferContainer = {
|
||||||
}
|
}
|
||||||
|
|
||||||
let Input = {
|
let Input = {
|
||||||
|
counter: 0,
|
||||||
|
stamp: textarea => {
|
||||||
|
return [Input.counter,
|
||||||
|
textarea.selectionStart, textarea.selectionEnd, textarea.value]
|
||||||
|
},
|
||||||
|
|
||||||
complete: textarea => {
|
complete: textarea => {
|
||||||
if (textarea.selectionStart !== textarea.selectionEnd)
|
if (textarea.selectionStart !== textarea.selectionEnd)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
// Cancel any previous autocomplete, and ensure applicability.
|
||||||
|
Input.counter++
|
||||||
|
let state = Input.stamp(textarea)
|
||||||
rpc.send({
|
rpc.send({
|
||||||
command: 'BufferComplete',
|
command: 'BufferComplete',
|
||||||
bufferName: bufferCurrent,
|
bufferName: bufferCurrent,
|
||||||
text: textarea.value,
|
text: textarea.value,
|
||||||
position: textarea.selectionEnd,
|
position: textarea.selectionEnd,
|
||||||
}).then(resp => {
|
}).then(resp => {
|
||||||
|
if (!Input.stamp(textarea).every((v, k) => v === state[k]))
|
||||||
|
return
|
||||||
|
|
||||||
// TODO: Somehow display remaining options, or cycle through.
|
// TODO: Somehow display remaining options, or cycle through.
|
||||||
if (resp.completions.length)
|
if (resp.completions.length)
|
||||||
textarea.setRangeText(resp.completions[0],
|
textarea.setRangeText(resp.completions[0],
|
||||||
|
@ -456,8 +468,6 @@ let Input = {
|
||||||
// TODO: And perhaps on other actions, too.
|
// TODO: And perhaps on other actions, too.
|
||||||
rpc.send({command: 'Active'})
|
rpc.send({command: 'Active'})
|
||||||
|
|
||||||
// TODO: Cancel any current autocomplete.
|
|
||||||
|
|
||||||
let textarea = event.currentTarget
|
let textarea = event.currentTarget
|
||||||
let handled = false
|
let handled = false
|
||||||
switch (event.keyCode) {
|
switch (event.keyCode) {
|
||||||
|
|
Loading…
Reference in New Issue