mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 17:37:57 +01:00
Better array option completion handling. Closes issue #159.
--HG-- extra : rebase_source : d5673d1bd406ab7096e2e7f73e8412972585a069
This commit is contained in:
@@ -849,6 +849,12 @@ const Commands = Module("commands", {
|
||||
if (opt.type) {
|
||||
let orig = arg;
|
||||
arg = opt.type.parse(arg);
|
||||
|
||||
if (complete && isArray(arg)) {
|
||||
args.completeFilter = arg[arg.length - 1];
|
||||
args.completeStart += orig.length - args.completeFilter.length;
|
||||
}
|
||||
|
||||
if (arg == null || (typeof arg == "number" && isNaN(arg))) {
|
||||
if (!complete || orig != "" || args.completeStart != str.length)
|
||||
fail("Invalid argument for " + opt.type.description + " option: " + optname);
|
||||
@@ -937,7 +943,10 @@ const Commands = Module("commands", {
|
||||
if (args.completeOpt) {
|
||||
let opt = args.completeOpt;
|
||||
let context = complete.fork(opt.names[0], args.completeStart);
|
||||
let arg = args[opt.names[0]];
|
||||
context.filter = args.completeFilter;
|
||||
if (isArray(arg))
|
||||
context.filters.push(function (item) arg.indexOf(item.text) === -1);
|
||||
if (typeof opt.completer == "function")
|
||||
var compl = opt.completer(context, args);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user