Merge pull request #1730 from danyaPostfactum/autoinsert

Add autoinsert feature to the completer.
This commit is contained in:
Harutyun Amirjanyan 2013-12-23 03:27:09 -08:00
commit 92dba7d44c

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