mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 13:22:28 +01:00
Make wop=sort actually do something
This commit is contained in:
@@ -112,6 +112,8 @@ liberator.Completion = function () //{{{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (liberator.options.get("wildoptions").has("sort"))
|
||||||
|
filtered = filtered.sort(function (a, b) liberator.util.ciCompare(a[0], b[0]));;
|
||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,6 +153,8 @@ liberator.Completion = function () //{{{
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (liberator.options.get("wildoptions").has("sort"))
|
||||||
|
filtered = filtered.sort(function (a, b) liberator.util.ciCompare(a[0], b[0]));;
|
||||||
return filtered;
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,36 +312,49 @@ liberator.Completion = function () //{{{
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
liberator.dump("eval(" + liberator.util.escapeString(arg) + ")");
|
// liberator.dump("eval(" + liberator.util.escapeString(arg) + ")");
|
||||||
return window.eval(arg);
|
return window.eval(arg);
|
||||||
}
|
}
|
||||||
catch(e) {}
|
catch(e) {}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/* Search the object for strings starting with @key.
|
/* Search the object for strings starting with @key.
|
||||||
* If @fn is defined, slice @offset characters from
|
* If @last is defined, key is a quoted string, it's
|
||||||
* the results and map them via @fn.
|
* wrapped in @last after @offset characters are sliced
|
||||||
|
* off of it and it's quoted.
|
||||||
*/
|
*/
|
||||||
function objectKeys(objects, key, fn, offset, last)
|
function objectKeys(objects, key, last, offset)
|
||||||
{
|
{
|
||||||
if (!(objects instanceof Array))
|
if (!(objects instanceof Array))
|
||||||
objects = [objects];
|
objects = [objects];
|
||||||
|
|
||||||
let iter = function (obj)
|
let iter = function (obj)
|
||||||
{
|
{
|
||||||
let iter = Iterator(obj);
|
let iterator = (function ()
|
||||||
|
{
|
||||||
|
for (let k in obj)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
yield [k, obj[k]];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
yield [k, "inaccessable"]
|
||||||
|
}
|
||||||
|
})();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ("__iterator__" in obj)
|
if ("__iterator__" in obj)
|
||||||
{
|
{
|
||||||
let oldIter = obj.__iterator__;
|
let oldIter = obj.__iterator__;
|
||||||
delete obj.__iterator__;
|
delete obj.__iterator__;
|
||||||
iter = Iterator(obj);
|
iterator = Iterator(obj);
|
||||||
obj.__iterator__ = oldIter;
|
obj.__iterator__ = oldIter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
return iter;
|
return iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
let compl = [];
|
let compl = [];
|
||||||
@@ -354,18 +371,19 @@ liberator.Completion = function () //{{{
|
|||||||
if (["string", "number", "boolean"].indexOf(type) > -1)
|
if (["string", "number", "boolean"].indexOf(type) > -1)
|
||||||
type += ": " + String(v).replace("\n", "\\n", "g");
|
type += ": " + String(v).replace("\n", "\\n", "g");
|
||||||
if (type == "function")
|
if (type == "function")
|
||||||
type += ": " + String(v).replace(/{(.|\n)*/, "{ ... }");
|
type += ": " + String(v).replace(/{(.|\n)*/, "{ ... }"); /* } vim */
|
||||||
|
|
||||||
compl.push([k, type]);
|
compl.push([k, type]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fn)
|
if (last != undefined)
|
||||||
{
|
{
|
||||||
compl.forEach(function (a) a[0] = fn(a[0].substr(offset)));
|
compl.forEach(function (a) a[0] = liberator.util.escapeString(a[0].substr(offset), last));
|
||||||
key = last + key.substr(offset)
|
key = last + key.substr(offset)
|
||||||
}
|
}
|
||||||
compl = buildLongestStartingSubstring(compl, key);
|
else
|
||||||
return compl;
|
compl = compl.filter(function (a) /^[\w$][\w\d$]*$/.test(a[0]));
|
||||||
|
return buildLongestStartingSubstring(compl, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
let stack = [];
|
let stack = [];
|
||||||
@@ -502,7 +520,7 @@ liberator.Completion = function () //{{{
|
|||||||
let obj = preEval + str.substring(get(-3, 0, STATEMENTS), get(-2)[OFFSET]);
|
let obj = preEval + str.substring(get(-3, 0, STATEMENTS), get(-2)[OFFSET]);
|
||||||
let key = preEval + str.substring(get(-2)[OFFSET] + 1, top[OFFSET]) + "''";
|
let key = preEval + str.substring(get(-2)[OFFSET] + 1, top[OFFSET]) + "''";
|
||||||
key = eval(key);
|
key = eval(key);
|
||||||
return [top[OFFSET], objectKeys(obj, key + string, liberator.util.escapeString, key.length, last)];
|
return [top[OFFSET], objectKeys(obj, key + string, last, key.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is this an object reference? */
|
/* Is this an object reference? */
|
||||||
@@ -755,7 +773,10 @@ liberator.Completion = function () //{{{
|
|||||||
filtered.push(elem);
|
filtered.push(elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
return filtered.concat(additionalCompletions);
|
filtered = filtered.concat(additionalCompletions);
|
||||||
|
if (liberator.options.get("wildoptions").has("sort"))
|
||||||
|
filtered = filtered.sort(function (a, b) liberator.util.ciCompare(a[0], b[0]));;
|
||||||
|
return filtered;
|
||||||
},
|
},
|
||||||
|
|
||||||
// generic helper function which checks if the given "items" array pass "filter"
|
// generic helper function which checks if the given "items" array pass "filter"
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ liberator.util = { //{{{
|
|||||||
yield ary[i];
|
yield ary[i];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
ciCompare: function (a, b)
|
||||||
|
{
|
||||||
|
return String.localeCompare(a.toLowerCase(), b.toLowerCase());
|
||||||
|
},
|
||||||
|
|
||||||
clip: function (str, length)
|
clip: function (str, length)
|
||||||
{
|
{
|
||||||
return str.length <= length ? str : str.substr(0, length - 3) + "...";
|
return str.length <= length ? str : str.substr(0, length - 3) + "...";
|
||||||
@@ -161,9 +166,10 @@ liberator.util = { //{{{
|
|||||||
return str.replace(/([\\{}()[\].?*+])/g, "\\$1");
|
return str.replace(/([\\{}()[\].?*+])/g, "\\$1");
|
||||||
},
|
},
|
||||||
|
|
||||||
escapeString: function (str)
|
escapeString: function (str, delimiter)
|
||||||
{
|
{
|
||||||
return '"' + str.replace(/([\\'])/g, "\\$1") + '"';
|
delimiter = delimiter || '"';
|
||||||
|
return delimiter + str.replace(/([\\'"])/g, "\\$1") + delimiter;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Flatten an array:
|
// Flatten an array:
|
||||||
|
|||||||
Reference in New Issue
Block a user