mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CmdConfig: Do not leave empty line upon variable removal
This commit is contained in:
parent
bf5f246168
commit
0868ba757c
1 changed files with 9 additions and 2 deletions
|
@ -107,8 +107,10 @@ int CmdConfig::unsetConfigVariable (std::string name, bool confirmation /* = fal
|
|||
bool change = false;
|
||||
|
||||
std::vector <std::string>::iterator line;
|
||||
for (line = contents.begin (); line != contents.end (); ++line)
|
||||
for (line = contents.begin (); line != contents.end (); )
|
||||
{
|
||||
bool lineDeleted = false;
|
||||
|
||||
// If there is a comment on the line, it must follow the pattern.
|
||||
std::string::size_type comment = line->find ("#");
|
||||
std::string::size_type pos = line->find (name + "=");
|
||||
|
@ -123,10 +125,15 @@ int CmdConfig::unsetConfigVariable (std::string name, bool confirmation /* = fal
|
|||
if (!confirmation ||
|
||||
confirm (format (STRING_CMD_CONFIG_CONFIRM3, name)))
|
||||
{
|
||||
*line = "";
|
||||
// vector::erase method returns a valid iterator to the next object
|
||||
line = contents.erase (line);
|
||||
lineDeleted = true;
|
||||
change = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (! lineDeleted)
|
||||
line++;
|
||||
}
|
||||
|
||||
if (change)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue