summaryrefslogtreecommitdiff
path: root/editor/code_editor.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-06-11 15:07:09 +0200
committerGitHub <noreply@github.com>2019-06-11 15:07:09 +0200
commit7842f4ca5c95becd19ada485f55aefde9f328468 (patch)
tree1b8a0f409a9c59ca253193047d03609083b3cc0c /editor/code_editor.cpp
parentd8877d2df5440b04c4a9c7eeced3c48cf6661536 (diff)
parent7fbb6d986ffe6101af1e062daeb9e1aa203684a6 (diff)
Merge pull request #29262 from DarknessCatt/issue-27476
Automatically add new line to scripts
Diffstat (limited to 'editor/code_editor.cpp')
-rw-r--r--editor/code_editor.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 33adb33c8c..4a440510db 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -804,6 +804,24 @@ void CodeTextEditor::trim_trailing_whitespace() {
}
}
+void CodeTextEditor::insert_final_newline() {
+ int final_line = text_editor->get_line_count() - 1;
+
+ String line = text_editor->get_line(final_line);
+
+ //length 0 means it's already an empty line,
+ //no need to add a newline
+ if (line.length() > 0 && !line.ends_with("\n")) {
+ text_editor->begin_complex_operation();
+
+ line += "\n";
+ text_editor->set_line(final_line, line);
+
+ text_editor->end_complex_operation();
+ text_editor->update();
+ }
+}
+
void CodeTextEditor::convert_indent_to_spaces() {
int indent_size = EditorSettings::get_singleton()->get("text_editor/indent/size");
String indent = "";