1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-27 05:55:45 +01:00

Fix JS completion eval cache.

This commit is contained in:
Kris Maglione
2008-12-03 10:33:48 -05:00
parent c070c0a00b
commit a221d2644d

View File

@@ -75,12 +75,13 @@ function CompletionContext(editor, name, offset)
else else
this.editor = editor; this.editor = editor;
this.compare = function (a, b) String.localeCompare(a.text, b.text); this.compare = function (a, b) String.localeCompare(a.text, b.text);
this.filterFunc = function (items) this.filterFunc = function (items)
{ {
let self = this; let self = this;
return this.filters.reduce( return this.filters.
function (res, filter) res.filter(function (item) filter.call(self, item)), reduce(function (res, filter) res.filter(function (item) filter.call(self, item)),
items); items);
} }
this.filters = [function (item) { this.filters = [function (item) {
let text = Array.concat(this.getKey(item, "text")); let text = Array.concat(this.getKey(item, "text"));
@@ -146,8 +147,7 @@ CompletionContext.prototype = {
}); });
let substrings = lists.reduce( let substrings = lists.reduce(
function (res, list) res.filter( function (res, list) res.filter(function (str) list.some(function (s) s.substr(0, str.length) == str)),
function (str) list.some(function (s) s.substr(0, str.length) == str)),
lists.pop()); lists.pop());
if (!substrings) // FIXME: How is this undefined? if (!substrings) // FIXME: How is this undefined?
return []; return [];
@@ -642,8 +642,7 @@ function Completion() //{{{
context[EVAL_TMP] = tmp; context[EVAL_TMP] = tmp;
try try
{ {
let res = liberator.eval(arg, context); return cache[key] = liberator.eval(arg, context);
return res;
} }
catch (e) catch (e)
{ {
@@ -838,6 +837,8 @@ function Completion() //{{{
let res = functions.some(function (idx) idx >= start && idx < end); let res = functions.some(function (idx) idx >= start && idx < end);
if (!res || self.context.tabPressed || key in cache.eval) if (!res || self.context.tabPressed || key in cache.eval)
return false; return false;
liberator.dump(cache.eval[key]);
liberator.dumpStack();
self.context.waitingForTab = true; self.context.waitingForTab = true;
return true; return true;
} }
@@ -1600,6 +1601,7 @@ function Completion() //{{{
return true; return true;
}); });
}); });
context.completions = completions;
}, },
// filter a list of urls // filter a list of urls