diff --git a/content/commands.js b/content/commands.js index 724b40ef..fe8f1b30 100644 --- a/content/commands.js +++ b/content/commands.js @@ -456,6 +456,7 @@ function Commands() //{{{ argCount = "*"; var args = []; // parsed options + args.__iterator__ = util.Array.iterator2; args.string = str; // for access to the unparsed string args.literalArg = ""; diff --git a/content/completion.js b/content/completion.js index 82bea015..abe2dfe4 100644 --- a/content/completion.js +++ b/content/completion.js @@ -75,8 +75,8 @@ function CompletionContext(editor, name, offset) this.filterFunc = function (items) { let self = this; - return this.filters.reduce(function (res, filter) - res.filter(function (item) filter.call(self, item)), + return this.filters.reduce( + function (res, filter) res.filter(function (item) filter.call(self, item)), items); } this.filters = [function (item) { @@ -120,6 +120,7 @@ CompletionContext.prototype = { }); return { start: minStart, items: util.Array.flatten(items), longestSubstring: this.longestAllSubstring } }, + // Temporary get allSubstrings() { let self = this; @@ -132,16 +133,19 @@ CompletionContext.prototype = { }); return util.Array.uniq(util.Array.flatten(items), true); }, + // Temporary get longestAllSubstring() { let substrings = this.allSubstrings; - return substrings.reduce(function (res, str) - res.filter(function (s) { + // Filter out any matches that don't match for all contexts + substrings = substrings.reduce( + function (res, str) res.filter(function (s) { let len = Math.min(s.length, str.length); return str.substr(0, len) == s.substr(0, len) }), - substrings) - .reduce(function (a, b) a.length > b.length ? a : b, ""); + substrings); + // Find the longest match + return substrings.reduce(function (a, b) a.length > b.length ? a : b, ""); }, get caret() (this.editor ? this.editor.selection.getRangeAt(0).startOffset : this.value.length) - this.offset, @@ -300,8 +304,8 @@ CompletionContext.prototype = { start = idx + 1; } } - substrings = items.reduce(function (res, item) - res.filter(function (str) compare(fixCase(item.unquoted || item.text), str)), + substrings = items.reduce( + function (res, item) res.filter(function (str) compare(fixCase(item.unquoted || item.text), str)), substrings); let quote = this.quote; if (quote) @@ -340,8 +344,8 @@ CompletionContext.prototype = { let reverse = start > end; start = Math.max(0, start || 0); end = Math.min(items.length, end != null ? end : items.length); - return util.map(util.range(start, end, reverse), - function (i) cache[i] = cache[i] || util.xmlToDom(self.createRow(items[i]), doc)); + for (let i in util.range(start, end, reverse)) + yield [i, cache[i] = cache[i] || util.xmlToDom(self.createRow(items[i]), doc)]; }, fork: function fork(name, offset, self, completer) @@ -441,12 +445,6 @@ function Completion() //{{{ const cleanEval = _cleanEval; delete modules._cleanEval; - // the completion substrings, used for showing the longest common match - var cacheFilter = {} - var cacheResults = {} - var substrings = []; - var historyCache = []; - function Javascript() { let json = Components.classes["@mozilla.org/dom/json;1"] @@ -953,12 +951,6 @@ function Completion() //{{{ } }, - // returns the longest common substring - // used for the 'longest' setting for wildmode - get longestSubstring() substrings.reduce(function (a, b) a.length > b.length ? a : b, ""), - - get substrings() substrings.slice(), - runCompleter: function (name, filter) { let context = CompletionContext(filter); @@ -1170,15 +1162,6 @@ function Completion() //{{{ // provides completions for ex commands, including their arguments ex: function ex(context) { - this.filterMap = null; - substrings = []; - if (context.filter.indexOf(cacheFilter["ex"]) != 0) - { - cacheFilter = {}; - cacheResults = {}; - } - cacheFilter["ex"] = context.filter; - // if there is no space between the command name and the cursor // then get completions of the command name let [count, cmd, bang, args] = commands.parseCommand(context.filter); diff --git a/content/options.js b/content/options.js index ae3f255e..c0661ba8 100644 --- a/content/options.js +++ b/content/options.js @@ -786,7 +786,7 @@ function Options() //{{{ //var length = names.length; //for (let i = 0, name = names[i]; i < length; name = names[++i]) - for (let [,name] in Iterator(args)) + for (let [,name] in args) { var name = args[i]; var reference = liberator.variableReference(name); diff --git a/content/style.js b/content/style.js index 63ba5ef0..621c9c27 100644 --- a/content/style.js +++ b/content/style.js @@ -37,7 +37,7 @@ function Highlights(name, store, serial) CompIcon>img max-width: 16px; max-height: 16px; vertical-align: middle; CompResult width: 45%; overflow: hidden; CompDesc color: gray; width: 50%; - CompLess text-align: center; height: .5ex; line-height: .5ex; + CompLess text-align: center; height: .5ex; line-height: .5ex; padding-top: 1ex; CompLess:after content: "\2303" /* Unicode up arrowhead */ CompMore text-align: center; height: .5ex; line-height: .5ex; CompMore:after content: "\2304" /* Unicode down arrowhead */ diff --git a/content/ui.js b/content/ui.js index c78cc3e5..de0de3e7 100644 --- a/content/ui.js +++ b/content/ui.js @@ -1310,7 +1310,7 @@ function ItemList(id) //{{{ commandline.updateOutputHeight(false); } - function getCompletion(index) completionElements[index - startIndex]; + function getCompletion(index) completionElements.snapshotItem(index - startIndex); function init() { @@ -1328,15 +1328,16 @@ function ItemList(id) //{{{ doc.body.replaceChild(div, doc.body.firstChild); items.contextList.forEach(function init_eachContext(context) { + delete context.cache.nodes; if (!context.items.length) return; - context.cache.nodes = {}; + context.cache.nodes = []; dom(