mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 13:37:20 +02:00
Bug #1001
- Actual resolution of Bug #1001. The Edit command was actually changing the working directory without going back to the original one afterwards.
This commit is contained in:
parent
e1407437e0
commit
b1e63e575a
3 changed files with 12 additions and 5 deletions
|
@ -31,6 +31,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <assert.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -395,8 +396,8 @@ int Context::dispatch (std::string &out)
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commands["help"])
|
assert (commands["help"]);
|
||||||
return commands["help"]->execute (out);
|
return commands["help"]->execute (out);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -629,7 +629,6 @@ bool CmdEdit::editFile (Task& task)
|
||||||
// Create a temp file name in data.location.
|
// Create a temp file name in data.location.
|
||||||
std::stringstream file;
|
std::stringstream file;
|
||||||
file << "task." << getpid () << "." << task.id << ".task";
|
file << "task." << getpid () << "." << task.id << ".task";
|
||||||
std::string path = location._data + "/" + file.str ();
|
|
||||||
|
|
||||||
// Determine the output date format, which uses a hierarchy of definitions.
|
// Determine the output date format, which uses a hierarchy of definitions.
|
||||||
// rc.dateformat.edit
|
// rc.dateformat.edit
|
||||||
|
@ -638,10 +637,13 @@ bool CmdEdit::editFile (Task& task)
|
||||||
if (dateformat == "")
|
if (dateformat == "")
|
||||||
dateformat = context.config.get ("dateformat");
|
dateformat = context.config.get ("dateformat");
|
||||||
|
|
||||||
// Format the contents, T -> text, write to a file.
|
// Change directory for the editor
|
||||||
std::string before = formatTask (task, dateformat);
|
char* current_dir = get_current_dir_name ();
|
||||||
int ignored = chdir (location._data.c_str ());
|
int ignored = chdir (location._data.c_str ());
|
||||||
++ignored; // Keep compiler quiet.
|
++ignored; // Keep compiler quiet.
|
||||||
|
|
||||||
|
// Format the contents, T -> text, write to a file.
|
||||||
|
std::string before = formatTask (task, dateformat);
|
||||||
File::write (file.str (), before);
|
File::write (file.str (), before);
|
||||||
|
|
||||||
// Determine correct editor: .taskrc:editor > $VISUAL > $EDITOR > vi
|
// Determine correct editor: .taskrc:editor > $VISUAL > $EDITOR > vi
|
||||||
|
@ -711,6 +713,8 @@ ARE_THESE_REALLY_HARMFUL:
|
||||||
|
|
||||||
// Cleanup.
|
// Cleanup.
|
||||||
File::remove (file.str ());
|
File::remove (file.str ());
|
||||||
|
ignored = chdir (current_dir);
|
||||||
|
free (current_dir);
|
||||||
return changes;
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Uri.h>
|
#include <Uri.h>
|
||||||
#include <Transport.h>
|
#include <Transport.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
@ -131,6 +132,7 @@ int CmdMerge::execute (std::string& output)
|
||||||
context.a3.push_back (Arg (uri._data, Arg::cat_literal));
|
context.a3.push_back (Arg (uri._data, Arg::cat_literal));
|
||||||
|
|
||||||
std::string out;
|
std::string out;
|
||||||
|
assert (context.commands["push"]);
|
||||||
context.commands["push"]->execute (out);
|
context.commands["push"]->execute (out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue