mirror of
https://github.com/embarklabs/neo-blessed.git
synced 2025-01-13 12:35:05 +00:00
Added a new function to do a regexp match on ritems
This commit is contained in:
parent
11ba4dad59
commit
d498c0b7a1
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user