logic: refresh only files where content changed

This commit is contained in:
mlangkabel
2017-09-11 09:56:18 +02:00
parent 99f54eedbc
commit 41348f5130
2 changed files with 26 additions and 4 deletions
+24 -4
View File
@@ -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<TextAccess> storedFileContent = m_storage->getFileContent(info.path);
std::shared_ptr<TextAccess> 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;
}