Fix bug and clarify async autocomplete result gathering
@SamyPesse’s “left: total - (i + 1)” was flawed because it only would work if all completers were async
This commit is contained in:
parent
c52278a64e
commit
cbbbf1c539
1 changed files with 3 additions and 2 deletions
|
|
@ -206,7 +206,7 @@ var Autocomplete = function() {
|
||||||
callback(null, {
|
callback(null, {
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
matches: matches,
|
matches: matches,
|
||||||
left: total - (i + 1)
|
finished: (--total === 0)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -255,8 +255,9 @@ var Autocomplete = function() {
|
||||||
// Save current gatherCompletions session, session is close when a match is insert
|
// Save current gatherCompletions session, session is close when a match is insert
|
||||||
var _id = this.gatherCompletionsId;
|
var _id = this.gatherCompletionsId;
|
||||||
this.gatherCompletions(this.editor, function(err, results) {
|
this.gatherCompletions(this.editor, function(err, results) {
|
||||||
|
// Only detach if result gathering is finished
|
||||||
var doDetach = function() {
|
var doDetach = function() {
|
||||||
if (results.left > 0) return;
|
if (!results.finished) return;
|
||||||
return this.detach();
|
return this.detach();
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue