logic: Fixes in and with TextAccess
* fixed Textaccess removing last line with single character when loading from string * fixed file comparison using wrong index ranges
This commit is contained in:
@@ -551,11 +551,15 @@ bool Project::didFileChange(const FileInfo& info) const
|
||||
{
|
||||
std::shared_ptr<TextAccess> storedFileContent = m_storage->getFileContent(info.path);
|
||||
std::shared_ptr<TextAccess> diskFileContent = TextAccess::createFromFile(diskFileInfo.path);
|
||||
if (diskFileContent->getLineCount() == storedFileContent->getLineCount())
|
||||
|
||||
const std::vector<std::string>& diskFileLines = diskFileContent->getAllLines();
|
||||
const std::vector<std::string>& storedFileLines = storedFileContent->getAllLines();
|
||||
|
||||
if (diskFileLines.size() == storedFileLines.size())
|
||||
{
|
||||
for (size_t i = 0; i < diskFileContent->getLineCount(); i++)
|
||||
for (size_t i = 0; i < diskFileLines.size(); i++)
|
||||
{
|
||||
if (diskFileContent->getLine(i) != storedFileContent->getLine(i))
|
||||
if (diskFileLines[i] != storedFileLines[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ std::vector<std::string> TextAccess::getLines(const unsigned int firstLineNumber
|
||||
return std::vector<std::string>(first, last);
|
||||
}
|
||||
|
||||
std::vector<std::string> TextAccess::getAllLines() const
|
||||
const std::vector<std::string>& TextAccess::getAllLines() const
|
||||
{
|
||||
return m_lines;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ std::vector<std::string> TextAccess::splitStringByLines(const std::string& text)
|
||||
index = text.find('\n', prevIndex);
|
||||
}
|
||||
|
||||
if (prevIndex < text.length() - 1)
|
||||
if (prevIndex < text.length())
|
||||
{
|
||||
result.push_back(text.substr(prevIndex));
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
* @param lastLineNumber: starts with 1
|
||||
*/
|
||||
std::vector<std::string> getLines(const unsigned int firstLineNumber, const unsigned int lastLineNumber);
|
||||
std::vector<std::string> getAllLines() const;
|
||||
const std::vector<std::string>& getAllLines() const;
|
||||
std::string getText() const;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user