mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
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.
This commit is contained in:
parent
c1b0998887
commit
cef51697ee
1 changed files with 24 additions and 0 deletions
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue