1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

Projucer: Make the source code editor respect line endings when loading and saving a file and add an option to set the preferred line feed for a project

This commit is contained in:
ed 2018-11-27 17:28:36 +00:00
parent 7b09d14695
commit b8a4e00cb4
11 changed files with 96 additions and 56 deletions

View file

@ -63,7 +63,23 @@ void SourceCodeDocument::reloadInternal()
{
jassert (codeDoc != nullptr);
modDetector.updateHash();
codeDoc->applyChanges (getFile().loadFileAsString());
auto fileContent = getFile().loadFileAsString();
auto lineFeed = [&]() -> const char*
{
if (fileContent.contains ("\r\n"))
return "\r\n";
if (fileContent.contains ("\n"))
return "\n";
return project->getProjectLineFeed().toRawUTF8();
}();
codeDoc->setNewLineCharacters (lineFeed);
codeDoc->applyChanges (fileContent);
codeDoc->setSavePoint();
}