Bug #1056
- Fix #1056: the 'projects' command now outputs abstract parents and reduces repetition by not printing parent names in front of children names. - Project name indentation is not affected by the first character being a period and/or the last character being a period. - Unit tests for above.
This commit is contained in:
committed by
Paul Beckingham
parent
a3242f7b5b
commit
be5dc8ab90
36
src/util.cpp
36
src/util.cpp
@@ -602,10 +602,42 @@ const std::string indentProject (
|
||||
// Count the delimiters in *i.
|
||||
std::string prefix = "";
|
||||
std::string::size_type pos = 0;
|
||||
std::string::size_type lastpos = 0;
|
||||
while ((pos = project.find (delimiter, pos + 1)) != std::string::npos)
|
||||
prefix += whitespace;
|
||||
{
|
||||
if (pos != project.size () - 1)
|
||||
{
|
||||
prefix += whitespace;
|
||||
lastpos = pos;
|
||||
}
|
||||
}
|
||||
|
||||
return prefix + project;
|
||||
std::string child = "";
|
||||
if (lastpos == 0)
|
||||
child = project;
|
||||
else
|
||||
child = project.substr (lastpos + 1);
|
||||
|
||||
return prefix + child;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::vector <std::string> extractParents (
|
||||
const std::string& project,
|
||||
const char& delimiter /* = '.' */)
|
||||
{
|
||||
std::vector <std::string> vec;
|
||||
std::string::size_type pos = 0;
|
||||
std::string::size_type copyUntil = 0;
|
||||
while ((copyUntil = project.find (delimiter, pos + 1)) != std::string::npos)
|
||||
{
|
||||
if (copyUntil != project.size () - 1)
|
||||
vec.push_back (project.substr (0, copyUntil));
|
||||
pos = copyUntil;
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user