1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-08 06:04:12 +01:00

Fix help tag indexing for automagically generated index tags.

This commit is contained in:
Kris Maglione
2011-02-20 17:11:16 -05:00
parent 12c8074057
commit deccf88dd0
2 changed files with 23 additions and 13 deletions

View File

@@ -208,14 +208,16 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, },
options: params.options || [] options: params.options || []
}); });
if (params.index) if (params.index)
this.indices[params.index] = function () { this.indices[params.index] = function () {
let results = array((params.iterateIndex || params.iterate).call(params, commands.get(name).newArgs())) let results = array((params.iterateIndex || params.iterate).call(params, commands.get(name).newArgs()))
.array.sort(function (a, b) String.localeCompare(a.name, b.name)); .array.sort(function (a, b) String.localeCompare(a.name, b.name));
let tags = services["dactyl:"].HELP_TAGS;
for (let obj in values(results)) { for (let obj in values(results)) {
let res = dactyl.generateHelp(obj, null, null, true); let res = dactyl.generateHelp(obj, null, null, true);
if (!set.has(services["dactyl:"].HELP_TAGS, obj.helpTag)) if (!set.has(tags, obj.helpTag))
res[1].@tag = obj.helpTag; res[1].@tag = obj.helpTag;
yield res; yield res;
@@ -794,7 +796,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
default xml namespace = NS; default xml namespace = NS;
overlayMap["index"] = function () ['text/xml;charset=UTF-8', overlayMap["index"] = ['text/xml;charset=UTF-8',
'<?xml version="1.0"?>\n' + '<?xml version="1.0"?>\n' +
'<overlay xmlns="' + NS + '">\n' + '<overlay xmlns="' + NS + '">\n' +
unescape(encodeURI( // UTF-8 handling hack. unescape(encodeURI( // UTF-8 handling hack.
@@ -804,6 +806,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}</dl>, <>{"\n\n"}</>))) + }</dl>, <>{"\n\n"}</>))) +
'\n</overlay>']; '\n</overlay>'];
addTags("index", util.httpGet("dactyl://help-overlay/index").responseXML);
addTags("index", util.httpGet("dactyl://help/index").responseXML); addTags("index", util.httpGet("dactyl://help/index").responseXML);
this.helpInitialized = true; this.helpInitialized = true;

View File

@@ -895,7 +895,12 @@ var Options = Module("options", {
ret.optionValue = ret.option.get(ret.scope); ret.optionValue = ret.option.get(ret.scope);
ret.values = ret.option.parse(ret.value); try {
ret.values = ret.option.parse(ret.value);
}
catch (e) {
ret.error = e;
}
return ret; return ret;
}, },
@@ -1095,21 +1100,23 @@ var Options = Module("options", {
return completion.option(context, opt.scope, prefix); return completion.option(context, opt.scope, prefix);
} }
let option = opt.option; function error(length, message) {
if (!option) { context.message = message;
context.message = "No such option: " + opt.name; context.highlight(0, length, "SPELLCHECK");
context.highlight(0, opt.name.length, "SPELLCHECK");
return;
} }
let option = opt.option;
if (!option)
return error(opt.name.length, "No such option: " + opt.name);
context.advance(context.filter.indexOf("=")); context.advance(context.filter.indexOf("="));
if (option.type == "boolean") { if (option.type == "boolean")
context.message = "Trailing characters"; return error(context.filter.length, "Trailing characters");
context.highlight(0, context.filter.length, "SPELLCHECK");
return;
}
context.advance(1); context.advance(1);
if (opt.error)
return error(context.filter.length, opt.error);
if (opt.get || opt.reset || !option || prefix) if (opt.get || opt.reset || !option || prefix)
return null; return null;