mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CmdConfig: Added recording of undoable transactions
This commit is contained in:
parent
7d5befb607
commit
8870ba6bd0
1 changed files with 21 additions and 0 deletions
|
@ -72,7 +72,13 @@ static bool setConfigVariable (Database& database, const Rules& rules, std::stri
|
||||||
rules.get (name),
|
rules.get (name),
|
||||||
value)))
|
value)))
|
||||||
{
|
{
|
||||||
|
auto before = line;
|
||||||
line = line.substr (0, pos) + name + " = " + value;
|
line = line.substr (0, pos) + name + " = " + value;
|
||||||
|
|
||||||
|
database.undoTxnStart ();
|
||||||
|
database.undoTxn ("config", before, line);
|
||||||
|
database.undoTxnEnd ();
|
||||||
|
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +107,13 @@ static bool setConfigVariable (Database& database, const Rules& rules, std::stri
|
||||||
rules.get (name),
|
rules.get (name),
|
||||||
value)))
|
value)))
|
||||||
{
|
{
|
||||||
|
auto before = line;
|
||||||
line = line.substr (0, pos) + leaf + " " + value;
|
line = line.substr (0, pos) + leaf + " " + value;
|
||||||
|
|
||||||
|
database.undoTxnStart ();
|
||||||
|
database.undoTxn ("config", before, line);
|
||||||
|
database.undoTxnEnd ();
|
||||||
|
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,6 +135,11 @@ static bool setConfigVariable (Database& database, const Rules& rules, std::stri
|
||||||
|
|
||||||
// Add new line.
|
// Add new line.
|
||||||
lines.push_back (name + " = " + JSON2::encode (value));
|
lines.push_back (name + " = " + JSON2::encode (value));
|
||||||
|
|
||||||
|
database.undoTxnStart ();
|
||||||
|
database.undoTxn ("config", "", lines.back ());
|
||||||
|
database.undoTxnEnd ();
|
||||||
|
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,6 +184,10 @@ static int unsetConfigVariable (Database& database, const Rules& rules, std::str
|
||||||
if (! confirmation ||
|
if (! confirmation ||
|
||||||
confirm (format ("Are you sure you want to remove '{1}'?", name)))
|
confirm (format ("Are you sure you want to remove '{1}'?", name)))
|
||||||
{
|
{
|
||||||
|
database.undoTxnStart ();
|
||||||
|
database.undoTxn ("config", line, "");
|
||||||
|
database.undoTxnEnd ();
|
||||||
|
|
||||||
line = "";
|
line = "";
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue