Fix :set completion when -add switch is given
This commit is contained in:
parent
5938712d1f
commit
7346220e38
|
@ -1016,19 +1016,22 @@ const CommandDesc set_option_cmd = {
|
||||||
CommandParameters params, size_t token_to_complete,
|
CommandParameters params, size_t token_to_complete,
|
||||||
ByteCount pos_in_token) -> Completions
|
ByteCount pos_in_token) -> Completions
|
||||||
{
|
{
|
||||||
if (token_to_complete == 0)
|
const bool add = params.size() > 1 and params[0] == "-add";
|
||||||
return { 0_byte, params[0].length(),
|
const int start = add ? 1 : 0;
|
||||||
complete(params[0], pos_in_token, scopes) };
|
|
||||||
else if (token_to_complete == 1)
|
if (token_to_complete == start)
|
||||||
return { 0_byte, params[1].length(),
|
return { 0_byte, params[start].length(),
|
||||||
GlobalScope::instance().option_registry().complete_option_name(params[1], pos_in_token) };
|
complete(params[start], pos_in_token, scopes) };
|
||||||
else if (token_to_complete == 2 and
|
else if (token_to_complete == start + 1)
|
||||||
GlobalScope::instance().option_registry().option_exists(params[1]))
|
return { 0_byte, params[start + 1].length(),
|
||||||
|
GlobalScope::instance().option_registry().complete_option_name(params[start + 1], pos_in_token) };
|
||||||
|
else if (not add and token_to_complete == start + 2 and
|
||||||
|
GlobalScope::instance().option_registry().option_exists(params[start + 1]))
|
||||||
{
|
{
|
||||||
OptionManager& options = get_scope(params[0], context).options();
|
OptionManager& options = get_scope(params[start], context).options();
|
||||||
String val = options[params[1]].get_as_string();
|
String val = options[params[start + 1]].get_as_string();
|
||||||
if (prefix_match(val, params[2]))
|
if (prefix_match(val, params[start + 2]))
|
||||||
return { 0_byte, params[2].length(), { std::move(val) } };
|
return { 0_byte, params[start + 2].length(), { std::move(val) } };
|
||||||
}
|
}
|
||||||
return Completions{};
|
return Completions{};
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue
Block a user