summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2022-08-21 18:38:28 +0200
committerMaxime Coste <mawww@kakoune.org>2022-08-21 18:38:28 +0200
commit13a95b0ba0105754239db84b6bf71bd7c6d339a9 (patch)
treedc1921047878c18ada2b74e307ef473b726adf0e /src
parentd076c033e7fc9d5a5d4dacaab6a8d12b4000c1ab (diff)
parent23fcf771608fe48d548930fe0097286fbace1ef4 (diff)
Merge remote-tracking branch 'krobelus/set-remove-autoinfo'
Diffstat (limited to 'src')
-rw-r--r--src/commands.cc11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/commands.cc b/src/commands.cc
index 6715fd05..a5f9955d 100644
--- a/src/commands.cc
+++ b/src/commands.cc
@@ -1617,11 +1617,11 @@ const CommandDesc source_cmd = {
static String option_doc_helper(const Context& context, CommandParameters params)
{
- const bool add = params.size() > 1 and params[0] == "-add";
- if (params.size() < 2 + (add ? 1 : 0))
+ const bool is_switch = params.size() > 1 and (params[0] == "-add" or params[0] == "-remove");
+ if (params.size() < 2 + (is_switch ? 1 : 0))
return "";
- auto desc = GlobalScope::instance().option_registry().option_desc(params[1 + (add ? 1 : 0)]);
+ auto desc = GlobalScope::instance().option_registry().option_desc(params[1 + (is_switch ? 1 : 0)]);
if (not desc or desc->docstring().empty())
return "";
@@ -1652,9 +1652,6 @@ const CommandDesc set_option_cmd = {
CommandParameters params, size_t token_to_complete,
ByteCount pos_in_token) -> Completions
{
- const bool add = params.size() > 1 and params[0] == "-add";
- const int start = add ? 1 : 0;
-
static constexpr auto scopes = { "global", "buffer", "window", "current" };
if (token_to_complete == 0)
@@ -1666,7 +1663,7 @@ const CommandDesc set_option_cmd = {
else if (token_to_complete == 2 and params[2].empty() and
GlobalScope::instance().option_registry().option_exists(params[1]))
{
- OptionManager& options = get_scope(params[start], context).options();
+ OptionManager& options = get_scope(params[0], context).options();
return {0_byte, params[2].length(),
{options[params[1]].get_as_string(Quoting::Kakoune)},
Completions::Flags::Quoted};