From dfb12466974d846717ef2e15b6b9839076d11443 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 5 May 2014 12:55:04 +0100 Subject: [PATCH] Complete option values with the current value of the option Fixes #32 --- src/commands.cc | 8 ++++++++ src/option_manager.hh | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/commands.cc b/src/commands.cc index 45c323829..fbed8daab 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -786,6 +786,14 @@ const CommandDesc set_option_cmd = { return { 0_byte, params[1].length(), options.complete_option_name(params[1], pos_in_token) }; } + else if (token_to_complete == 2 and + GlobalOptions::instance().option_exists(params[1])) + { + OptionManager& options = get_options(params[0], context); + String val = options[params[1]].get_as_string(); + if (prefix_match(val, params[2])) + return { 0_byte, params[2].length(), { std::move(val) } }; + } return Completions{}; }, [](const ParametersParser& parser, Context& context) diff --git a/src/option_manager.hh b/src/option_manager.hh index d7e225fe8..244e15558 100644 --- a/src/option_manager.hh +++ b/src/option_manager.hh @@ -220,6 +220,11 @@ public: value, std::move(checker)}); return *m_options.back(); } + + bool option_exists(const String& name) const + { + return find_option(m_options, name) != m_options.end(); + } private: std::vector> m_descs; };