refactor fuzzyFind.
This commit is contained in:
parent
5b249d3fec
commit
4cf8be871d
|
@ -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') {
|
||||
|
|
Loading…
Reference in New Issue