diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp index 09fb24520d2..f8e20c7e3ea 100644 --- a/src/plugins/projectexplorer/projectnodes.cpp +++ b/src/plugins/projectexplorer/projectnodes.cpp @@ -648,13 +648,13 @@ void FolderNode::addNestedNodes(std::vector > &&files, const Utils::FilePath parentDir = f->filePath().parentDir(); const auto it = std::lower_bound(fileNodesPerDir.begin(), fileNodesPerDir.end(), parentDir, [](const DirWithNodes &nad, const Utils::FilePath &dir) { return nad.first < dir; }); - if (it == fileNodesPerDir.end() || it->first < parentDir) { + if (it != fileNodesPerDir.end() && it->first == parentDir) { + it->second.emplace_back(std::move(f)); + } else { DirWithNodes dirWithNodes; dirWithNodes.first = parentDir; dirWithNodes.second.emplace_back(std::move(f)); fileNodesPerDir.insert(it, std::move(dirWithNodes)); - } else { - it->second.emplace_back(std::move(f)); } }