1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-03 09:14:13 +01:00

Match only complete words in :lk filters. Should we maybe support regexps instead?

This commit is contained in:
Kris Maglione
2011-01-03 15:22:34 -05:00
parent 5aa7450973
commit f41e245cb1
3 changed files with 20 additions and 5 deletions

View File

@@ -176,9 +176,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
function (args) {
let results = array(params.iterate(args))
.sort(function (a, b) String.localeCompare(a.name, b.name));
if (args.length)
results = results.filter(function (item) args.map(String.toLowerCase)
.every(function (arg) (item.name + item.description).toLowerCase().indexOf(arg) >= 0));
let filters = args.map(function (arg) RegExp("\\b" + util.regexp.escape(arg) + "\\b", "i"));
if (filters.length)
results = results.filter(function (item) filters.every(function (re) re.test(item.name + item.description)));
commandline.commandOutput(
template.usage(results, params.format));
},