diff --git a/content/bookmarks.js b/content/bookmarks.js index f740e90e..64a09b74 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -76,7 +76,6 @@ function Bookmarks() //{{{ let uri = ioService.newURI(node.uri, null, null); let keyword = bookmarksService.getKeywordForBookmark(node.itemId); let tags = taggingService.getTagsForURI(uri, {}) || []; - //return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId)); return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId)); } diff --git a/content/completion.js b/content/completion.js index 0306dbf7..fe0d6759 100644 --- a/content/completion.js +++ b/content/completion.js @@ -68,6 +68,7 @@ function CompletionContext(editor, name, offset) this.reset(); } this.name = name || ""; + this.cache = {}; this._items = []; // FIXME this.selectionTypes = {}; } @@ -266,37 +267,36 @@ function Completion() //{{{ completion.filterMap = [null, function (v) template.highlight(v, true)]; - //if (cacheFilter.js === cacheKey) - // return cacheResults.js; - //cacheFilter.js = cacheKey; + let [obj, key] = objects; + let cache = this.context.cache.objects || {}; + this.context.cache.objects = cache; + if (key in cache) + return cache[key]; // Can't use the cache. Build a member list. - compl = []; - for (let [,obj] in Iterator(objects)) - { - // Things we can dereference - if (["object", "string", "function"].indexOf(typeof obj) == -1) - continue; - if (!obj) - continue; + let compl = []; + // Things we can dereference + if (["object", "string", "function"].indexOf(typeof obj) == -1) + return []; + if (!obj) + return []; - // XPCNativeWrappers, etc, don't show all accessible - // members until they're accessed, so, we look at - // the wrappedJSObject instead, and return any keys - // available in the object itself. - let orig = obj; - if (obj.wrappedJSObject) - obj = obj.wrappedJSObject; - // v[0] in orig and orig[v[0]] catch different cases. XPCOM - // objects are problematic, to say the least. - compl.push([v for (v in this.iter(obj)) if (v[0] in orig || orig[v[0]] !== undefined)]) - // And if wrappedJSObject happens to be available, - // return that, too. - if (orig.wrappedJSObject) - compl.push([["wrappedJSObject", obj]]); - } + // XPCNativeWrappers, etc, don't show all accessible + // members until they're accessed, so, we look at + // the wrappedJSObject instead, and return any keys + // available in the object itself. + let orig = obj; + if (obj.wrappedJSObject) + obj = obj.wrappedJSObject; + // v[0] in orig and orig[v[0]] catch different cases. XPCOM + // objects are problematic, to say the least. + compl.push([v for (v in this.iter(obj)) if (v[0] in orig || orig[v[0]] !== undefined)]) + // And if wrappedJSObject happens to be available, + // return that, too. + if (orig.wrappedJSObject) + compl.push([["wrappedJSObject", obj]]); compl = util.Array.flatten(compl); - return cacheResults.js = compl; + return cache[key] = compl; } this.filter = function filter(compl, key, last, offset) @@ -327,9 +327,9 @@ function Completion() //{{{ this.eval = function eval(arg, key, tmp) { - if (!("eval" in cacheResults)) - cacheResults.eval = {}; - let cache = cacheResults.eval; + if (!("eval" in this.context.cache)) + this.context.cache.eval = {}; + let cache = this.context.cache.eval; if (!key) key = arg; @@ -525,6 +525,7 @@ function Completion() //{{{ let statement = get(frame, 0, STATEMENTS) || 0; // Current statement. let prev = statement; let obj; + let cacheKey; for (let [i, dot] in Iterator(get(frame)[DOTS].concat(stop))) { if (dot < statement) @@ -538,7 +539,7 @@ function Completion() //{{{ cacheKey = str.substring(statement, dot); obj = self.eval(s, cacheKey, obj); } - return [[obj, str.substring(statement, stop + 1)]]; + return [[obj, cacheKey]] } function getObjKey(frame) @@ -565,7 +566,7 @@ function Completion() //{{{ { let ctxt = this.context.fork(obj[1], top[OFFSET]); ctxt.title = [obj[1]]; - ctxt.items = this.filter(compl || this.objectKeys(obj[0]), key + (string || ""), last, key.length); + ctxt.items = this.filter(compl || this.objectKeys(obj), key + (string || ""), last, key.length); } } @@ -627,7 +628,7 @@ function Completion() //{{{ try { - var completer = obj[func].liberatorCompleter; + var completer = obj[0][0][func].liberatorCompleter; } catch (e) {} if (!completer) @@ -645,10 +646,11 @@ function Completion() //{{{ }); args.push(key); - let compl = completer.call(this, func, obj, string, args); + let compl = completer.call(this, func, obj[0][0], string, args); if (!(compl instanceof Array)) compl = [v for (v in compl)]; key = this.eval(key); + obj[0][1] += "." + func + "(..."; return complete.call(this, obj, key, compl, string, last); } diff --git a/content/liberator.js b/content/liberator.js index fcb3985a..466a3744 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -383,7 +383,10 @@ const liberator = (function () //{{{ { args = args.string; - let method = args[0] == ":" ? "execute" : "eval"; + if (args[0] == ":") + var method = function () liberator.execute(args); + else + method = liberator.eval("(function () {" + args + "})"); try { @@ -395,7 +398,7 @@ const liberator = (function () //{{{ for (let i in util.interruptableRange(0, count, 500)) { let now = Date.now(); - liberator[method](args); + method(); total += Date.now() - now; } @@ -437,10 +440,7 @@ const liberator = (function () //{{{ else { var beforeTime = Date.now(); - if (args && args[0] == ":") - liberator.execute(args); - else - liberator.eval(args); + method(); if (special) return;