diff --git a/content/completion.js b/content/completion.js index c2cfdab1..9e71e24b 100644 --- a/content/completion.js +++ b/content/completion.js @@ -108,6 +108,7 @@ CompletionContext.prototype = { { delete this.cache.filtered; delete this.cache.filter; + this.cache.rows = []; this.hasItems = items.length > 0; this._completions = items; let self = this; @@ -126,10 +127,14 @@ CompletionContext.prototype = { get generate() !this._generate ? null : function () { - this._completions = this._generate.call(this); + let updateAsync = this.updateAsync; // XXX + this.updateAsync = false; + this.completions = this._generate.call(this); + this.updateAsync = updateAsync; + this.cache.offset = this.offset; this.cache.key = this.key; - return this._completions; + return this.completions; }, set generate(arg) { @@ -217,15 +222,24 @@ CompletionContext.prototype = { { let self = this; let items = this.items; - if (!items) - return []; - let reverse = start > end; start = Math.max(0, start || 0); end = Math.min(items.length, end ? end : items.length); return util.map(util.range(start, end, reverse), function (i) items[i]); }, + getRows: function (start, end, doc) + { + let self = this; + let items = this.items; + let cache = this.cache.rows; + let reverse = start > end; + start = Math.max(0, start || 0); + end = Math.min(items.length, end ? end : items.length); + return util.map(util.range(start, end, reverse), + function (i) cache[i] = cache[i] || util.xmlToDom(self.createRow(items[i]), doc)); + }, + fork: function fork(name, offset, completer, self) { let context = new CompletionContext(this, name, offset); diff --git a/content/template.js b/content/template.js index 8abe74a4..09d3effc 100644 --- a/content/template.js +++ b/content/template.js @@ -32,7 +32,7 @@ const template = { return <>{xml}; }, - completionRow: function completionRow(context, item, class) + completionRow: function completionRow(item, class) { if (typeof icon == "function") icon = icon(); @@ -43,8 +43,8 @@ const template = { } else { - var text = context.process[0].call(context, item, item.text || context.getKey(item, "text")); - var desc = context.process[1].call(context, item, context.getKey(item, "description")); + var text = this.process[0].call(this, item, item.text || this.getKey(item, "text")); + var desc = this.process[1].call(this, item, this.getKey(item, "description")); } return