summaryrefslogtreecommitdiffstats
path: root/editor/plugins/script_editor_plugin.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-05-30 11:47:28 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-05-30 11:47:28 +0200
commit838eb5a0fdcfa0e0f368a6d33a0f712db90c9719 (patch)
tree565c508efbc85bac44c367ba697277882b0c1df6 /editor/plugins/script_editor_plugin.cpp
parentffad49f1693cc292df88955573e8fe197a41bcd0 (diff)
parentb4c1634b52f619ca8987b67ecee2640310781aa7 (diff)
downloadredot-engine-838eb5a0fdcfa0e0f368a6d33a0f712db90c9719.tar.gz
Merge pull request #87099 from bitwise-aiden/ba-add-trim-newlines
Implement `trim_final_newlines` setting and functionality
Diffstat (limited to 'editor/plugins/script_editor_plugin.cpp')
-rw-r--r--editor/plugins/script_editor_plugin.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 0a0909ec9f..4812c623c9 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1008,6 +1008,10 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
se->trim_trailing_whitespace();
}
+ if (trim_final_newlines_on_save) {
+ se->trim_final_newlines();
+ }
+
se->insert_final_newline();
if (convert_indent_on_save) {
@@ -1402,6 +1406,10 @@ void ScriptEditor::_menu_option(int p_option) {
current->trim_trailing_whitespace();
}
+ if (trim_final_newlines_on_save) {
+ current->trim_final_newlines();
+ }
+
current->insert_final_newline();
if (convert_indent_on_save) {
@@ -2602,6 +2610,10 @@ void ScriptEditor::save_current_script() {
current->trim_trailing_whitespace();
}
+ if (trim_final_newlines_on_save) {
+ current->trim_final_newlines();
+ }
+
current->insert_final_newline();
if (convert_indent_on_save) {
@@ -2646,6 +2658,10 @@ void ScriptEditor::save_all_scripts() {
se->trim_trailing_whitespace();
}
+ if (trim_final_newlines_on_save) {
+ se->trim_final_newlines();
+ }
+
se->insert_final_newline();
if (!se->is_unsaved()) {
@@ -2883,6 +2899,7 @@ void ScriptEditor::_apply_editor_settings() {
}
trim_trailing_whitespace_on_save = EDITOR_GET("text_editor/behavior/files/trim_trailing_whitespace_on_save");
+ trim_final_newlines_on_save = EDITOR_GET("text_editor/behavior/files/trim_final_newlines_on_save");
convert_indent_on_save = EDITOR_GET("text_editor/behavior/files/convert_indent_on_save");
members_overview_enabled = EDITOR_GET("text_editor/script_list/show_members_overview");
@@ -4307,6 +4324,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
edit_pass = 0;
trim_trailing_whitespace_on_save = EDITOR_GET("text_editor/behavior/files/trim_trailing_whitespace_on_save");
+ trim_final_newlines_on_save = EDITOR_GET("text_editor/behavior/files/trim_final_newlines_on_save");
convert_indent_on_save = EDITOR_GET("text_editor/behavior/files/convert_indent_on_save");
ScriptServer::edit_request_func = _open_script_request;