Added a new function to do a regexp match on ritems

This commit is contained in:
Bulkan Evcimen 2014-05-07 21:55:53 +10:00
parent 11ba4dad59
commit d498c0b7a1

View File

@ -4147,7 +4147,7 @@ function List(options) {
}
self.options.search(function(searchString){
self.select(self.getItemIndex(searchString));
self.select(self.fuzzyFind(searchString));
self.screen.render();
})
}
@ -4245,6 +4245,17 @@ List.prototype.appendItem = function(item) {
}
};
List.prototype.fuzzyFind = function(searchString) {
var index = this.getItemIndex(this.selected);
for (var i = 0; i < this.ritems.length; i++){
if (this.ritems[i].match(new RegExp('^' + searchString))){
return i;
}
}
return index;
}
List.prototype.getItemIndex = function(child) {
if (typeof child === 'number') {
return child;