mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 10:57:58 +01:00
Add -max option to :hist, default to 1000
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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(
|
||||
<div highlight="Completions">
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user