diff --git a/lib/widget.js b/lib/widget.js index 5cd779b..71c78c4 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -4172,7 +4172,7 @@ function List(options) { return; } - self.options.search(function(searchString){ + return self.options.search(function(searchString){ self.select(self.fuzzyFind(searchString)); self.screen.render(); }) @@ -4271,16 +4271,17 @@ List.prototype.appendItem = function(item) { } }; -List.prototype.fuzzyFind = function(searchString) { +List.prototype.fuzzyFind = function(search) { var index = this.getItemIndex(this.selected); for (var i = 0; i < this.ritems.length; i++){ - if (this.ritems[i].match(new RegExp('^' + searchString))){ + if (this.ritems[i].indexOf(search) === 0) { return i; } } + return index; -} +}; List.prototype.getItemIndex = function(child) { if (typeof child === 'number') {