mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
#9 TI-1: Make undo work with config actions
This commit is contained in:
parent
0688e3ba07
commit
d230e40313
2 changed files with 74 additions and 1 deletions
|
@ -37,6 +37,27 @@ static void undoIntervalAction(UndoAction& action, Database& database)
|
|||
database.modifyInterval (after, before);
|
||||
}
|
||||
|
||||
static void undoConfigAction (UndoAction& action, Rules &rules, Database& database)
|
||||
{
|
||||
const std::string& before = action.getBefore ();
|
||||
|
||||
if (before.empty ()) {
|
||||
const std::string& after = action.getAfter ();
|
||||
auto pos = after.find (' ');
|
||||
std::string name = after.substr (0, pos);
|
||||
|
||||
Rules::unsetConfigVariable (database, rules, name, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pos = before.find ('=');
|
||||
std::string name = before.substr (0, pos-1);
|
||||
std::string value = before.substr (pos+1, before.length ());
|
||||
|
||||
Rules::setConfigVariable (database, rules, name, value, false);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdUndo (Rules& rules, Database& database)
|
||||
{
|
||||
|
@ -66,7 +87,7 @@ int CmdUndo (Rules& rules, Database& database)
|
|||
}
|
||||
else if (type == "config")
|
||||
{
|
||||
throw "Undo of config actions not yet implemented!";
|
||||
undoConfigAction (action, rules, database);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue