diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index f4f56089..4223c9d9 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -300,11 +300,8 @@ bool Project::requestIndex(bool forceRefresh, bool needsFullRefresh) { if (info.path.exists()) { - FileInfo newFileInfo = FileSystem::getFileInfoForPath(info.path); - - if (newFileInfo.lastWriteTime > info.lastWriteTime) + if (didFileChange(info)) { - // file has been updated changedFilePaths.insert(info.path); } else @@ -547,3 +544,26 @@ bool Project::hasCxxSourceGroup() const } return false; } + +bool Project::didFileChange(const FileInfo& info) const +{ + FileInfo diskFileInfo = FileSystem::getFileInfoForPath(info.path); + if (diskFileInfo.lastWriteTime > info.lastWriteTime) + { + std::shared_ptr storedFileContent = m_storage->getFileContent(info.path); + std::shared_ptr diskFileContent = TextAccess::createFromFile(diskFileInfo.path); + if (diskFileContent->getLineCount() == storedFileContent->getLineCount()) + { + for (size_t i = 0; i < diskFileContent->getLineCount(); i++) + { + if (diskFileContent->getLine(i) != storedFileContent->getLine(i)) + { + return true; + } + } + return false; + } + return true; + } + return false; +} diff --git a/src/lib/project/Project.h b/src/lib/project/Project.h index a466cd8d..464e458d 100644 --- a/src/lib/project/Project.h +++ b/src/lib/project/Project.h @@ -8,6 +8,7 @@ #include "project/SourceGroup.h" +struct FileInfo; class FilePath; class PersistentStorage; class ProjectSettings; @@ -50,6 +51,7 @@ private: void buildIndex(const std::set& filesToIndex, const std::set& filesToClean, bool fullRefresh); bool hasCxxSourceGroup() const; + bool didFileChange(const FileInfo& info) const; std::shared_ptr m_settings; StorageAccessProxy* const m_storageAccessProxy;