From 2c004500292024f835698c1568a76559419b8277 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 18 Apr 2015 22:21:11 -0700 Subject: [PATCH] allow regexes for fuzzyfind. --- lib/widget.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/widget.js b/lib/widget.js index c6e2edc..398de54 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -5248,6 +5248,15 @@ List.prototype.appendItem = function(item) { List.prototype.fuzzyFind = function(search, back) { var index = this.getItemIndex(this.selected); var start = this.selected + (back ? -1 : 1); + + if (search[0] === '/' && search[search.length - 1] === '/') { + try { + search = new RegExp(search.slice(1, -1)); + } catch (e) { + ; + } + } + var finder = typeof search === 'string' ? function(item) { return !!~item.indexOf(search); } : search.test.bind(search);