diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2020-02-28 03:56:33 +0100 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2020-02-28 03:56:33 +0100 |
commit | 34cc1bd41f3d1ec67872f7862063d43f1c136711 (patch) | |
tree | 26f60a1980a64b755a76ac2b1724ccc70e7812b9 /gui | |
parent | bb754441c8acf70f82c1862a214e74164a403dc1 (diff) | |
download | nextpnr-34cc1bd41f3d1ec67872f7862063d43f1c136711.tar.gz nextpnr-34cc1bd41f3d1ec67872f7862063d43f1c136711.tar.bz2 nextpnr-34cc1bd41f3d1ec67872f7862063d43f1c136711.zip |
gui: Fix sorting order in TreeModel.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/treemodel.cc | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/gui/treemodel.cc b/gui/treemodel.cc index e300c74d..448c9794 100644 --- a/gui/treemodel.cc +++ b/gui/treemodel.cc @@ -97,12 +97,7 @@ void IdStringList::updateElements(Context *ctx, std::vector<IdString> elements) auto parts_a = alphaNumSplit(a->name()); auto parts_b = alphaNumSplit(b->name()); - // Short-circuit for different part count. - if (parts_a.size() != parts_b.size()) { - return parts_a.size() < parts_b.size(); - } - - for (size_t i = 0; i < parts_a.size(); i++) { + for (size_t i = 0; i < parts_a.size() && i < parts_b.size(); i++) { auto &part_a = parts_a.at(i); auto &part_b = parts_b.at(i); @@ -134,8 +129,8 @@ void IdStringList::updateElements(Context *ctx, std::vector<IdString> elements) return part_a < part_b; } - // Same string. - return false; + // One string is equal to or a subset of the other, compare length. + return parts_a.size() < parts_b.size(); }); } |