From 80e66ed1728a4b28cbb85dcd871aaee256298e19 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Mon, 12 Jun 2023 08:07:14 +0200 Subject: [PATCH] Python: preserve sorted state of project files Change-Id: I77cd9d9bac93a04d0e30beda8541862a1cd5371f Reviewed-by: Christian Stenger --- src/plugins/python/pythonproject.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/plugins/python/pythonproject.cpp b/src/plugins/python/pythonproject.cpp index 50ffe379943..c9bb0f0b6ce 100644 --- a/src/plugins/python/pythonproject.cpp +++ b/src/plugins/python/pythonproject.cpp @@ -302,12 +302,21 @@ bool PythonBuildSystem::addFiles(Node *, const FilePaths &filePaths, FilePaths * { const Utils::FilePath projectDir = projectDirectory(); + auto comp = [](const FileEntry &left, const FileEntry &right) { + return left.rawEntry < right.rawEntry; + }; + + const bool isSorted = std::is_sorted(m_files.begin(), m_files.end(), comp); + for (const FilePath &filePath : filePaths) { if (!projectDir.isSameDevice(filePath)) return false; m_files.append(FileEntry{filePath.relativePathFrom(projectDir).toString(), filePath}); } + if (isSorted) + std::sort(m_files.begin(), m_files.end(), comp); + return save(); }