From 23fcf771608fe48d548930fe0097286fbace1ef4 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Tue, 19 Jul 2022 23:07:59 +0200 Subject: [PATCH] Fix autoinfo for "set-option -remove" not showing option-specific info On a command prompt like "set-option -remove buffer aligntab " we fail to show the aligntab-specific info . Fix this by skipping a leading -remove, just like we skip -add. Add an explicit specialization of contains() because otherwise I'd need to write something like contains(Array{"-add", "remove"}, param) --- src/commands.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/commands.cc b/src/commands.cc index f08acb34..f8b9f9f9 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1631,11 +1631,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 "";