From cef51697eeebfe4159201af23e8702f5cd24b0de Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Thu, 9 Mar 2017 20:41:20 +0100 Subject: [PATCH] TI-29: Fix issue "timew config can't add new value" - Add code to enter a new value for a config which is defined by Rules.cpp but not found in the configuration file. --- src/commands/CmdConfig.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/commands/CmdConfig.cpp b/src/commands/CmdConfig.cpp index 9ddaf4a8..87f40edc 100644 --- a/src/commands/CmdConfig.cpp +++ b/src/commands/CmdConfig.cpp @@ -119,6 +119,30 @@ static bool setConfigVariable (Database& database, const Rules& rules, std::stri } } } + if (! found) + { + // Remove name + if (! confirmation || + confirm (format ("Are you sure you want to change the value of '{1}' from '{2}' to '{3}'?", + name, + rules.get (name), + value))) + { + // Add blank line required by rules. + if (lines.size () && + lines.back () != "") + lines.push_back (""); + + // Add new line. + lines.push_back (name + " = " + json::encode (value)); + + database.undoTxnStart (); + database.undoTxn ("config", "", lines.back()); + database.undoTxnEnd (); + + change = true; + } + } } else {