diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index c4fd7060..50154c01 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -39,6 +39,7 @@ var lang = require("./lib/lang"); var snippetManager = require("./snippets").snippetManager; var Autocomplete = function() { + this.autoInsert = true; this.keyboardHandler = new HashHandler(); this.keyboardHandler.bindKeys(this.commands); @@ -248,8 +249,11 @@ var Autocomplete = function() { this.completions = new FilteredList(matches); this.completions.setFilter(results.prefix); - if (!this.completions.filtered.length) + var filtered = this.completions.filtered; + if (!filtered.length) return this.detach(); + if (this.autoInsert && filtered.length == 1) + return this.insertMatch(filtered[0]); this.openPopup(this.editor, results.prefix, keepPopupPosition); }.bind(this)); };