Add autoinsert feature to the completer.

This commit is contained in:
DanyaPostfactum 2013-12-23 02:52:25 +10:00
commit ff42a13c4f

View file

@ -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));
};