From b43d9f914c77a834529416699faf2e34c37829ff Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 5 Oct 2011 19:57:39 -0400 Subject: [PATCH] Alias c_ to c_. --- common/content/commandline.js | 6 ++--- common/content/editor.js | 2 +- common/modules/completion.jsm | 45 +++++++++++++++++++++-------------- 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/common/content/commandline.js b/common/content/commandline.js index 473d009a..70c96201 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -1609,14 +1609,14 @@ var CommandLine = Module("commandline", { self.completions.onTab(keypressEvents[0]); }); - bind(["", ""], "Select the next matching completion group", + bind(["", "", ""], "Select the next matching completion group", function ({ keypressEvents, self }) { dactyl.assert(self.completions); self.completions.tabTimer.flush(); self.completions.select(self.completions.CTXT_DOWN); }); - bind(["", ""], "Select the previous matching completion group", + bind(["", "", ""], "Select the previous matching completion group", function ({ keypressEvents, self }) { dactyl.assert(self.completions); self.completions.tabTimer.flush(); @@ -2128,7 +2128,7 @@ var ItemList = Class("ItemList", { } }, - getRow: function getRow(idx) this.context.getRow(idx), + getRow: function getRow(idx) this.context.getRow(idx, this.doc), getOffset: function getOffset(idx) this.offsets.start + (idx || 0), diff --git a/common/content/editor.js b/common/content/editor.js index ddbdc1da..28c19af1 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -363,7 +363,7 @@ var Editor = Module("editor", { range.setStart(range.startContainer, range.endOffset - abbrev.lhs.length); this.mungeRange(range, function () abbrev.expand(this.element), true); } - }, + } }, { TextsIterator: Class("TextsIterator", { init: function init(range, context, after) { diff --git a/common/modules/completion.jsm b/common/modules/completion.jsm index 29fab699..683eb641 100644 --- a/common/modules/completion.jsm +++ b/common/modules/completion.jsm @@ -349,11 +349,15 @@ var CompletionContext = Class("CompletionContext", { * The prototype object for items returned by {@link items}. */ get itemPrototype() { + let self = this; let res = { highlight: "" }; + function result(quote) { + yield ["context", function () self]; yield ["result", quote ? function () quote[0] + util.trapErrors(1, quote, this.text) + quote[2] : function () this.text]; }; + for (let i in iter(this.keys, result(this.quote))) { let [k, v] = i; if (typeof v == "string" && /^[.[]/.test(v)) @@ -361,7 +365,7 @@ var CompletionContext = Class("CompletionContext", { // reference any variables. Don't bother with eval context. v = Function("i", "return i" + v); if (typeof v == "function") - res.__defineGetter__(k, function () Class.replaceProperty(this, k, v.call(this, this.item))); + res.__defineGetter__(k, function () Class.replaceProperty(this, k, v.call(this, this.item, self))); else res.__defineGetter__(k, function () Class.replaceProperty(this, k, this.item[v])); res.__defineSetter__(k, function (val) Class.replaceProperty(this, k, val)); @@ -636,7 +640,25 @@ var CompletionContext = Class("CompletionContext", { return iter.map(util.range(start, end, step), function (i) items[i]); }, - getRow: function getRow(idx) this.cache.rows && this.cache.rows[idx], + getRow: function getRow(idx, doc) { + let cache = this.cache.rows; + if (cache) { + if (!(idx in this.cache.rows)) + try { + cache[idx] = util.xmlToDom(this.createRow(this.items[idx]), + doc || this.doc); + } + catch (e) { + util.reportError(e); + cache[idx] = util.xmlToDom( +
+
  • {this.text} 
  • +
  • {e} 
  • +
    , doc || this.doc); + } + return cache[idx]; + } + }, getRows: function getRows(start, end, doc) { let self = this; @@ -647,22 +669,9 @@ var CompletionContext = Class("CompletionContext", { start = Math.max(0, start || 0); end = Math.min(items.length, end != null ? end : items.length); - for (let i in util.range(start, end, step)) { - if (!cache[i]) - try { - cache[i] = util.xmlToDom(self.createRow(items[i]), doc); - } - catch (e) { - util.reportError(e); - cache[i] = util.xmlToDom( -
    -
  • {items[i].text} 
  • -
  • {e} 
  • -
    , doc); - } - - yield [i, cache[i]]; - } + this.doc = doc; + for (let i in util.range(start, end, step)) + yield [i, this.getRow(i)]; }, /**