Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Fix runtimmecompil #45

Merged
merged 11 commits into from
Nov 3, 2019
Prev Previous commit
Next Next commit
code_editor.cpp: remove unwanted empty line at EOF
pthom committed Nov 3, 2019
commit ed40569adf929995157067ed9f0a41a669539351
12 changes: 10 additions & 2 deletions src/imgui_utils/code_editor.cpp
Original file line number Diff line number Diff line change
@@ -76,8 +76,16 @@ class OneCodeEditor

void save()
{
BABYLON::Filesystem::writeFileContents(_filePath.c_str(), _textEditor.GetText());
_fileContent_Saved = _textEditor.GetText();
std::string text = _textEditor.GetText();
// The code editor may add an unwanted additional
// empty line at the end of the text
if (!text.empty())
{
if (text[text.size() - 1] == '\n')
text = text.substr(0, text.size() - 1);
}
BABYLON::Filesystem::writeFileContents(_filePath.c_str(), text);
_fileContent_Saved = text;
}

private: