diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index c5109ae1..8bf3a401 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -206,7 +206,7 @@ var Autocomplete = function() { callback(null, { prefix: prefix, 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 var _id = this.gatherCompletionsId; this.gatherCompletions(this.editor, function(err, results) { + // Only detach if result gathering is finished var doDetach = function() { - if (results.left > 0) return; + if (!results.finished) return; return this.detach(); }.bind(this);