Skip to content

Commit

Permalink
Merge pull request #490 from baconpaul/subsort-481
Browse files Browse the repository at this point in the history
Sub-folder sorting. Closes #481
  • Loading branch information
baconpaul authored Feb 4, 2019
2 parents 3057df5 + c13a481 commit e0163d0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/common/SurgeStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ void SurgeStorage::refreshPatchlistAddDir(bool userDir, string subdir)
** scanning for names; setting the 'root' to everything without a slash
** and finding the parent in the name map for everything with a slash
*/

std::map<std::string,int> nameToLocalIndex;
int idx=0;
for (auto &pc : local_patch_category)
Expand All @@ -383,6 +384,23 @@ void SurgeStorage::refreshPatchlistAddDir(bool userDir, string subdir)
}
}

/*
** We need to sort the local patch category child to make sure subfolders remain
** sorted when displayed using the child data structure in the menu view.
*/

auto catCompare =
[this](const PatchCategory &c1, const PatchCategory &c2) -> bool
{
return _stricmp(c1.name.c_str(),c2.name.c_str()) < 0;
};
for (auto &pc : local_patch_category)
{
std::sort(pc.children.begin(), pc.children.end(), catCompare);
}



/*
** Then copy our local patch category onto the member and be done
*/
Expand Down

0 comments on commit e0163d0

Please sign in to comment.