mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 10:08:00 +01:00
Fix arg parser bugs. Add "Waiting..." message for incomplete completers.
This commit is contained in:
@@ -552,12 +552,15 @@ function Commands() //{{{
|
|||||||
args.quote = complQuote[quote] || complQuote[""];
|
args.quote = complQuote[quote] || complQuote[""];
|
||||||
}
|
}
|
||||||
let type = argTypes[opt[1]];
|
let type = argTypes[opt[1]];
|
||||||
if (type)
|
if (type && (!complete || arg != null))
|
||||||
{
|
{
|
||||||
|
liberator.dump("arg: " + arg);
|
||||||
arg = type.parse(arg);
|
arg = type.parse(arg);
|
||||||
if (arg == null || arg == NaN)
|
liberator.dump("arg: " + arg);
|
||||||
|
if (arg == null || (typeof arg == "number" && isNaN(arg)))
|
||||||
{
|
{
|
||||||
echoerr("Invalid argument for " + type.description + "option: " + optname);
|
liberator.dump("arg: " + arg);
|
||||||
|
echoerr("Invalid argument for " + type.description + " option: " + optname);
|
||||||
if (complete)
|
if (complete)
|
||||||
complete.highlight(args.completeStart, count - 1, "SPELLCHECK");
|
complete.highlight(args.completeStart, count - 1, "SPELLCHECK");
|
||||||
else
|
else
|
||||||
@@ -580,6 +583,8 @@ function Commands() //{{{
|
|||||||
|
|
||||||
args[opt[0][0]] = arg; // always use the first name of the option
|
args[opt[0][0]] = arg; // always use the first name of the option
|
||||||
i += optname.length + count;
|
i += optname.length + count;
|
||||||
|
if (i == str.length)
|
||||||
|
break outer;
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
// if it is invalid, just fall through and try the next argument
|
// if it is invalid, just fall through and try the next argument
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ function CompletionContext(editor, name, offset)
|
|||||||
self.contexts[name] = this;
|
self.contexts[name] = this;
|
||||||
self.filters = parent.filters.slice();
|
self.filters = parent.filters.slice();
|
||||||
self.incomplete = false;
|
self.incomplete = false;
|
||||||
|
self.message = null;
|
||||||
self.parent = parent;
|
self.parent = parent;
|
||||||
self.offset = parent.offset + (offset || 0);
|
self.offset = parent.offset + (offset || 0);
|
||||||
self.keys = util.cloneObject(parent.keys);
|
self.keys = util.cloneObject(parent.keys);
|
||||||
@@ -200,6 +201,9 @@ CompletionContext.prototype = {
|
|||||||
this.process = format.process || this.process;
|
this.process = format.process || this.process;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get message() this._message || (this.incomplete ? "Waiting..." : null),
|
||||||
|
set message(val) this._message = val,
|
||||||
|
|
||||||
get regenerate() this._generate && (!this.completions || !this.itemCache[this.key] || this.cache.offset != this.offset),
|
get regenerate() this._generate && (!this.completions || !this.itemCache[this.key] || this.cache.offset != this.offset),
|
||||||
set regenerate(val) { if (val) delete this.itemCache[this.key] },
|
set regenerate(val) { if (val) delete this.itemCache[this.key] },
|
||||||
|
|
||||||
@@ -1343,11 +1347,11 @@ function Completion() //{{{
|
|||||||
context.filterFunc = null;
|
context.filterFunc = null;
|
||||||
context.compare = null;
|
context.compare = null;
|
||||||
let timer = new util.Timer(50, 100, function (result) {
|
let timer = new util.Timer(50, 100, function (result) {
|
||||||
|
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
|
||||||
context.completions = [
|
context.completions = [
|
||||||
[result.getValueAt(i), result.getCommentAt(i), result.getImageAt(i)]
|
[result.getValueAt(i), result.getCommentAt(i), result.getImageAt(i)]
|
||||||
for (i in util.range(0, result.matchCount))
|
for (i in util.range(0, result.matchCount))
|
||||||
];
|
];
|
||||||
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
|
|
||||||
});
|
});
|
||||||
completionService.stopSearch();
|
completionService.stopSearch();
|
||||||
completionService.startSearch(context.filter, "", context.result, {
|
completionService.startSearch(context.filter, "", context.result, {
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ const liberator = (function () //{{{
|
|||||||
commands.add(["loadplugins", "lpl"],
|
commands.add(["loadplugins", "lpl"],
|
||||||
"Load all plugins immediately",
|
"Load all plugins immediately",
|
||||||
function () { liberator.loadPlugins(); },
|
function () { liberator.loadPlugins(); },
|
||||||
{ argCount: "0" );
|
{ argCount: "0" });
|
||||||
|
|
||||||
commands.add(["norm[al]"],
|
commands.add(["norm[al]"],
|
||||||
"Execute Normal mode commands",
|
"Execute Normal mode commands",
|
||||||
|
|||||||
@@ -699,7 +699,10 @@ function Options() //{{{
|
|||||||
context.advance(context.filter.indexOf("=") + 1);
|
context.advance(context.filter.indexOf("=") + 1);
|
||||||
|
|
||||||
if (!option)
|
if (!option)
|
||||||
|
{
|
||||||
|
context.message = "No such option: " + opt.name;
|
||||||
context.highlight(0, name.length, "SPELLCHECK");
|
context.highlight(0, name.length, "SPELLCHECK");
|
||||||
|
}
|
||||||
|
|
||||||
if (opt.get || opt.reset || !option || prefix)
|
if (opt.get || opt.reset || !option || prefix)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1417,6 +1417,8 @@ function ItemList(id) //{{{
|
|||||||
nodes.message.style.display = "none";
|
nodes.message.style.display = "none";
|
||||||
if (context.message)
|
if (context.message)
|
||||||
{
|
{
|
||||||
|
nodes.up.style.display = "none";
|
||||||
|
nodes.down.style.display = "none";
|
||||||
nodes.message.textContent = context.message;
|
nodes.message.textContent = context.message;
|
||||||
nodes.message.style.display = "block";
|
nodes.message.style.display = "block";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user