diff --git a/README.md b/README.md index 74506d4..18a8705 100644 --- a/README.md +++ b/README.md @@ -733,6 +733,8 @@ A scrollable list which can display selectable items. - __down(amount)__ - select item below selected. - __pick(callback)__ - show/focus list and pick an item. the callback is executed with the result. +- __fuzzyFind([string/regex/callback])__ - find an item based on its text + content. #### Form (from Box) diff --git a/lib/widget.js b/lib/widget.js index c8d08b0..a0d0b51 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -5355,6 +5355,7 @@ List.prototype.appendItem = function(item) { } }; +List.prototype.find = List.prototype.fuzzyFind = function(search, back) { var start = this.selected + (back ? -1 : 1); @@ -5381,17 +5382,17 @@ List.prototype.fuzzyFind = function(search, back) { if (!back) { for (var i = start; i < this.ritems.length; i++){ - if (test(this.ritems[i])) return i; + if (test(this.items[i].getText())) return i; } for (var i = 0; i < start; i++){ - if (test(this.ritems[i])) return i; + if (test(this.items[i].getText())) return i; } } else { for (var i = start; i >= 0; i--){ - if (test(this.ritems[i])) return i; + if (test(this.items[i].getText())) return i; } for (var i = this.ritems.length - 1; i > start; i--){ - if (test(this.ritems[i])) return i; + if (test(this.items[i].getText())) return i; } }