mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-19 00:05:45 +01:00
Match only complete words in :lk filters. Should we maybe support regexps instead?
This commit is contained in:
@@ -176,9 +176,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
function (args) {
|
function (args) {
|
||||||
let results = array(params.iterate(args))
|
let results = array(params.iterate(args))
|
||||||
.sort(function (a, b) String.localeCompare(a.name, b.name));
|
.sort(function (a, b) String.localeCompare(a.name, b.name));
|
||||||
if (args.length)
|
|
||||||
results = results.filter(function (item) args.map(String.toLowerCase)
|
let filters = args.map(function (arg) RegExp("\\b" + util.regexp.escape(arg) + "\\b", "i"));
|
||||||
.every(function (arg) (item.name + item.description).toLowerCase().indexOf(arg) >= 0));
|
if (filters.length)
|
||||||
|
results = results.filter(function (item) filters.every(function (re) re.test(item.name + item.description)));
|
||||||
|
|
||||||
commandline.commandOutput(
|
commandline.commandOutput(
|
||||||
template.usage(results, params.format));
|
template.usage(results, params.format));
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -273,7 +273,15 @@ function prototype(obj)
|
|||||||
|
|
||||||
function properties(obj, prototypes, debugger_) {
|
function properties(obj, prototypes, debugger_) {
|
||||||
let orig = obj;
|
let orig = obj;
|
||||||
let seen = {};
|
let seen = { dactylPropertyNames: true };
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ("dactylpropertynames" in obj && !prototypes)
|
||||||
|
for (let key in values(dactylpropertynames))
|
||||||
|
if (key in obj && !set.add(seen, key))
|
||||||
|
yield key;
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
|
||||||
for (; obj; obj = prototypes && prototype(obj)) {
|
for (; obj; obj = prototypes && prototype(obj)) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1168,11 +1168,16 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {object} tokens The tokens to substitute. @optional
|
* @param {object} tokens The tokens to substitute. @optional
|
||||||
*/
|
*/
|
||||||
regexp: update(function (expr, flags, tokens) {
|
regexp: update(function (expr, flags, tokens) {
|
||||||
|
if (isinstance(expr, ["RegExp"]))
|
||||||
|
expr = expr.source;
|
||||||
if (tokens)
|
if (tokens)
|
||||||
expr = String.replace(expr, /<(\w+)>/g, function (m, n1) set.has(tokens, n1) ? tokens[n1].source || tokens[n1] : m);
|
expr = String.replace(expr, /<(\w+)>/g, function (m, n1) set.has(tokens, n1) ? tokens[n1].source || tokens[n1] : m);
|
||||||
expr = String.replace(expr, /\/\/[^\n]*|\/\*[^]*?\*\//gm, "")
|
expr = String.replace(expr, /\/\/[^\n]*|\/\*[^]*?\*\//gm, "")
|
||||||
.replace(/\s+/g, "");
|
.replace(/\s+/g, "");
|
||||||
return RegExp(expr, flags);
|
return update(RegExp(expr, flags), {
|
||||||
|
closure: Class.Property(Object.getOwnPropertyDescriptor(Class.prototype, "closure")),
|
||||||
|
dactylPropertyNames: ["exec", "match", "test", "toSource", "toString", "global", "ignoreCase", "lastIndex", "multiLine", "source", "sticky"]
|
||||||
|
});
|
||||||
}, {
|
}, {
|
||||||
/**
|
/**
|
||||||
* Escapes Regular Expression special characters in *str*.
|
* Escapes Regular Expression special characters in *str*.
|
||||||
|
|||||||
Reference in New Issue
Block a user