diff --git a/content/bookmarks.js b/content/bookmarks.js index 493e9431..0c4132ad 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -725,11 +725,11 @@ function History() //{{{ commands.add(["hist[ory]", "hs"], "Show recently visited URLs", - function (args) { history.list(args.string, args.bang); }, + function (args) { history.list(args.join(" "), args.bang, args["-max"] || 1000); }, { bang: true, - literal: 0, - completer: function (context) completion.history(context) + completer: function (context) { context.quote = null, completion.history(context) }, + options: [[["-max", "-m"], options.OPTION_INT]] // completer: function (filter) completion.history(filter) }); @@ -803,12 +803,12 @@ function History() //{{{ }, // if openItems is true, open the matching history items in tabs rather than display - list: function list(filter, openItems) + list: function list(filter, openItems, maxItems) { if (!openItems) - return completion.listCompleter("history", filter); + return completion.listCompleter("history", filter, maxItems); - var items = this.get({ searchTerms: filter }, 1000); + var items = this.get({ searchTerms: filter }, maxItems); if (items.length) return liberator.open([i[0] for each (i in items)], liberator.NEW_TAB); diff --git a/content/completion.js b/content/completion.js index 801bc33d..b0592bf5 100644 --- a/content/completion.js +++ b/content/completion.js @@ -62,7 +62,7 @@ function CompletionContext(editor, name, offset) self[key] = parent[key]); if (self != this) return self; - ["_caret", "contextList", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value", "waitingForTab"].forEach(function (key) { + ["_caret", "contextList", "maxItems", "onUpdate", "selectionTypes", "tabPressed", "updateAsync", "value", "waitingForTab"].forEach(function (key) { self.__defineGetter__(key, function () this.top[key]); self.__defineSetter__(key, function (val) this.top[key] = val); }); @@ -271,6 +271,8 @@ CompletionContext.prototype = { delete this._substrings; let filtered = this.filterFunc(items.map(function (item) ({ text: self.getKey({ item: item }, "text"), item: item }))); + if (this.maxItems) + filtered = filtered.slice(0, this.maxItems); let quote = this.quote; if (quote) @@ -1117,14 +1119,13 @@ function Completion() //{{{ return filter.split(/\s+/).every(function strIndex(str) itemsStr.indexOf(str) > -1); }, - listCompleter: function listCompleter(name, filter) + listCompleter: function listCompleter(name, filter, maxItems) { let context = CompletionContext(filter || ""); context.fork.apply(context, ["list", 0, completion, name].concat(Array.slice(arguments, 2))); context = context.contexts["/list"]; - - while (context.incomplete) - liberator.threadYield(true, true); + context.maxItems = maxItems; + context.wait(); let list = template.generic(
@@ -1339,7 +1340,7 @@ function Completion() //{{{ context.compare = null; //context.background = true; context.regenerate = true; - context.generate = function () history.get(context.filter); + context.generate = function () history.get(context.filter, this.maxItems); }, get javascriptCompleter() javascript,