diff --git a/content/completion.js b/content/completion.js index bc1928c7..f72dc806 100644 --- a/content/completion.js +++ b/content/completion.js @@ -1338,7 +1338,14 @@ function Completion() //{{{ menuItem: function menuItem(filter) commands.get("emenu").completer(filter), // XXX - option: function option(filter) commands.get("set").completer(filter), // XXX + option: function option(context, scope) + { + context.title = ["Option"]; + context.keys = { text: "names", description: "description" }; + context.completions = options; + if (scope) + context.filters.push(function ({item: opt}) opt.scope & scope); + }, optionValue: function (context, name, op, curValue) { diff --git a/content/options.js b/content/options.js index aa93fde2..ada77719 100644 --- a/content/options.js +++ b/content/options.js @@ -685,30 +685,21 @@ function Options() //{{{ return; } - let prefix = (filter.match(/^(no|inv)/) || [""])[0]; + let opt = options.parseOpt(filter, modifiers); + let prefix = opt.prefix; if (prefix) - context.filter = filter = filter.substr(prefix.length); + context.advance(prefix.length); - let scope = modifiers && modifiers.scope || options.OPTION_SCOPE_BOTH; - - let opts = (opt for (opt in options) - if ((opt.scope & scope) && - (!prefix || opt.type == "boolean" || - prefix == "inv" && opt.value instanceof Array))); - - if (filter.indexOf("=") == -1) + if (context.filter.indexOf("=") == -1) { - context.title = ["Option"]; - context.quote = [prefix, util.identity, ""]; - context.keys = { text: "names", description: "description" }; - context.completions = opts; - return; + if (prefix) + context.filters.push(function ({item: opt}) opt.type == "boolean" || prefix == "inv" && opt.values instanceof Array); + return completion.option(context, opt.scope); } else if (prefix == "no") return; - let [name, value] = filter.split("=", 2); - let opt = options.parseOpt(filter, modifiers); + let [name, value] = context.filter.split("=", 2); let option = opt.option; context.advance(name.length + 1); @@ -915,7 +906,7 @@ function Options() //{{{ let matches, prefix, postfix, valueGiven; [matches, prefix, ret.name, postfix, valueGiven, ret.operator, ret.value] = - args.match(/^\s*(no|inv)?([a-z_]+)([?&!])?\s*(([-+^]?)=(.*))?\s*$/) || []; + args.match(/^\s*(no|inv)?([a-z_]*)([?&!])?\s*(([-+^]?)=(.*))?\s*$/) || []; ret.args = args; ret.onlyNonDefault = false; // used for :set to print non-default options