src: Let :set-register complete register names

This commit allows the `set-register` command to suggest candidates
named after punctuated registers, similarly to %reg{…} expansions.
This commit is contained in:
Frank LENORMAND 2020-02-09 15:31:08 +01:00
parent e9cf0f23f2
commit c0cb5db6a4

View File

@ -2365,7 +2365,12 @@ const CommandDesc set_register_cmd = {
ParameterDesc{{}, ParameterDesc::Flags::SwitchesAsPositional, 1}, ParameterDesc{{}, ParameterDesc::Flags::SwitchesAsPositional, 1},
CommandFlags::None, CommandFlags::None,
CommandHelper{}, CommandHelper{},
CommandCompleter{}, make_completer(
[](const Context& context, CompletionFlags flags,
const String& prefix, ByteCount cursor_pos) -> Completions {
return { 0_byte, cursor_pos,
RegisterManager::instance().complete_register_name(prefix, cursor_pos) };
}),
[](const ParametersParser& parser, Context& context, const ShellContext&) [](const ParametersParser& parser, Context& context, const ShellContext&)
{ {
RegisterManager::instance()[parser[0]].set(context, parser.positionals_from(1)); RegisterManager::instance()[parser[0]].set(context, parser.positionals_from(1));