Implement trim_final_newlines functionality
This commit is contained in:
parent
d4f726f3ef
commit
b4c1634b52
|
@ -1012,6 +1012,9 @@
|
||||||
<member name="text_editor/behavior/files/restore_scripts_on_load" type="bool" setter="" getter="">
|
<member name="text_editor/behavior/files/restore_scripts_on_load" type="bool" setter="" getter="">
|
||||||
If [code]true[/code], reopens scripts that were opened in the last session when the editor is reopened on a given project.
|
If [code]true[/code], reopens scripts that were opened in the last session when the editor is reopened on a given project.
|
||||||
</member>
|
</member>
|
||||||
|
<member name="text_editor/behavior/files/trim_final_newlines_on_save" type="bool" setter="" getter="">
|
||||||
|
If [code]true[/code], trims all empty newlines after the final newline when saving a script. Final newlines refer to the empty newlines found at the end of files. Since these serve no practical purpose, they can and should be removed to make version control diffs less noisy.
|
||||||
|
</member>
|
||||||
<member name="text_editor/behavior/files/trim_trailing_whitespace_on_save" type="bool" setter="" getter="">
|
<member name="text_editor/behavior/files/trim_trailing_whitespace_on_save" type="bool" setter="" getter="">
|
||||||
If [code]true[/code], trims trailing whitespace when saving a script. Trailing whitespace refers to tab and space characters placed at the end of lines. Since these serve no practical purpose, they can and should be removed to make version control diffs less noisy.
|
If [code]true[/code], trims trailing whitespace when saving a script. Trailing whitespace refers to tab and space characters placed at the end of lines. Since these serve no practical purpose, they can and should be removed to make version control diffs less noisy.
|
||||||
</member>
|
</member>
|
||||||
|
|
|
@ -1123,6 +1123,31 @@ void CodeTextEditor::trim_trailing_whitespace() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeTextEditor::trim_final_newlines() {
|
||||||
|
int final_line = text_editor->get_line_count() - 1;
|
||||||
|
int check_line = final_line;
|
||||||
|
|
||||||
|
String line = text_editor->get_line(check_line);
|
||||||
|
|
||||||
|
while (line.is_empty() && check_line > -1) {
|
||||||
|
--check_line;
|
||||||
|
|
||||||
|
line = text_editor->get_line(check_line);
|
||||||
|
}
|
||||||
|
|
||||||
|
++check_line;
|
||||||
|
|
||||||
|
if (check_line < final_line) {
|
||||||
|
text_editor->begin_complex_operation();
|
||||||
|
|
||||||
|
text_editor->remove_text(check_line, 0, final_line, 0);
|
||||||
|
|
||||||
|
text_editor->merge_overlapping_carets();
|
||||||
|
text_editor->end_complex_operation();
|
||||||
|
text_editor->queue_redraw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CodeTextEditor::insert_final_newline() {
|
void CodeTextEditor::insert_final_newline() {
|
||||||
int final_line = text_editor->get_line_count() - 1;
|
int final_line = text_editor->get_line_count() - 1;
|
||||||
String line = text_editor->get_line(final_line);
|
String line = text_editor->get_line(final_line);
|
||||||
|
|
|
@ -224,6 +224,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void trim_trailing_whitespace();
|
void trim_trailing_whitespace();
|
||||||
|
void trim_final_newlines();
|
||||||
void insert_final_newline();
|
void insert_final_newline();
|
||||||
|
|
||||||
enum CaseStyle {
|
enum CaseStyle {
|
||||||
|
|
|
@ -647,6 +647,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
||||||
|
|
||||||
// Behavior: Files
|
// Behavior: Files
|
||||||
_initial_set("text_editor/behavior/files/trim_trailing_whitespace_on_save", false);
|
_initial_set("text_editor/behavior/files/trim_trailing_whitespace_on_save", false);
|
||||||
|
_initial_set("text_editor/behavior/files/trim_final_newlines_on_save", true);
|
||||||
_initial_set("text_editor/behavior/files/autosave_interval_secs", 0);
|
_initial_set("text_editor/behavior/files/autosave_interval_secs", 0);
|
||||||
_initial_set("text_editor/behavior/files/restore_scripts_on_load", true);
|
_initial_set("text_editor/behavior/files/restore_scripts_on_load", true);
|
||||||
_initial_set("text_editor/behavior/files/convert_indent_on_save", true);
|
_initial_set("text_editor/behavior/files/convert_indent_on_save", true);
|
||||||
|
|
|
@ -1007,6 +1007,10 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
|
||||||
se->trim_trailing_whitespace();
|
se->trim_trailing_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trim_final_newlines_on_save) {
|
||||||
|
se->trim_final_newlines();
|
||||||
|
}
|
||||||
|
|
||||||
se->insert_final_newline();
|
se->insert_final_newline();
|
||||||
|
|
||||||
if (convert_indent_on_save) {
|
if (convert_indent_on_save) {
|
||||||
|
@ -1387,6 +1391,10 @@ void ScriptEditor::_menu_option(int p_option) {
|
||||||
current->trim_trailing_whitespace();
|
current->trim_trailing_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trim_final_newlines_on_save) {
|
||||||
|
current->trim_final_newlines();
|
||||||
|
}
|
||||||
|
|
||||||
current->insert_final_newline();
|
current->insert_final_newline();
|
||||||
|
|
||||||
if (convert_indent_on_save) {
|
if (convert_indent_on_save) {
|
||||||
|
@ -2567,6 +2575,10 @@ void ScriptEditor::save_current_script() {
|
||||||
current->trim_trailing_whitespace();
|
current->trim_trailing_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trim_final_newlines_on_save) {
|
||||||
|
current->trim_final_newlines();
|
||||||
|
}
|
||||||
|
|
||||||
current->insert_final_newline();
|
current->insert_final_newline();
|
||||||
|
|
||||||
if (convert_indent_on_save) {
|
if (convert_indent_on_save) {
|
||||||
|
@ -2611,6 +2623,10 @@ void ScriptEditor::save_all_scripts() {
|
||||||
se->trim_trailing_whitespace();
|
se->trim_trailing_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trim_final_newlines_on_save) {
|
||||||
|
se->trim_final_newlines();
|
||||||
|
}
|
||||||
|
|
||||||
se->insert_final_newline();
|
se->insert_final_newline();
|
||||||
|
|
||||||
if (!se->is_unsaved()) {
|
if (!se->is_unsaved()) {
|
||||||
|
@ -2848,6 +2864,7 @@ void ScriptEditor::_apply_editor_settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
trim_trailing_whitespace_on_save = EDITOR_GET("text_editor/behavior/files/trim_trailing_whitespace_on_save");
|
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");
|
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");
|
members_overview_enabled = EDITOR_GET("text_editor/script_list/show_members_overview");
|
||||||
|
@ -4265,6 +4282,7 @@ ScriptEditor::ScriptEditor(WindowWrapper *p_wrapper) {
|
||||||
|
|
||||||
edit_pass = 0;
|
edit_pass = 0;
|
||||||
trim_trailing_whitespace_on_save = EDITOR_GET("text_editor/behavior/files/trim_trailing_whitespace_on_save");
|
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");
|
convert_indent_on_save = EDITOR_GET("text_editor/behavior/files/convert_indent_on_save");
|
||||||
|
|
||||||
ScriptServer::edit_request_func = _open_script_request;
|
ScriptServer::edit_request_func = _open_script_request;
|
||||||
|
|
|
@ -174,6 +174,7 @@ public:
|
||||||
virtual void set_executing_line(int p_line) = 0;
|
virtual void set_executing_line(int p_line) = 0;
|
||||||
virtual void clear_executing_line() = 0;
|
virtual void clear_executing_line() = 0;
|
||||||
virtual void trim_trailing_whitespace() = 0;
|
virtual void trim_trailing_whitespace() = 0;
|
||||||
|
virtual void trim_final_newlines() = 0;
|
||||||
virtual void insert_final_newline() = 0;
|
virtual void insert_final_newline() = 0;
|
||||||
virtual void convert_indent() = 0;
|
virtual void convert_indent() = 0;
|
||||||
virtual void ensure_focus() = 0;
|
virtual void ensure_focus() = 0;
|
||||||
|
@ -408,6 +409,7 @@ class ScriptEditor : public PanelContainer {
|
||||||
|
|
||||||
bool open_textfile_after_create = true;
|
bool open_textfile_after_create = true;
|
||||||
bool trim_trailing_whitespace_on_save;
|
bool trim_trailing_whitespace_on_save;
|
||||||
|
bool trim_final_newlines_on_save;
|
||||||
bool convert_indent_on_save;
|
bool convert_indent_on_save;
|
||||||
bool external_editor_active;
|
bool external_editor_active;
|
||||||
|
|
||||||
|
|
|
@ -431,6 +431,10 @@ void ScriptTextEditor::trim_trailing_whitespace() {
|
||||||
code_editor->trim_trailing_whitespace();
|
code_editor->trim_trailing_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptTextEditor::trim_final_newlines() {
|
||||||
|
code_editor->trim_final_newlines();
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptTextEditor::insert_final_newline() {
|
void ScriptTextEditor::insert_final_newline() {
|
||||||
code_editor->insert_final_newline();
|
code_editor->insert_final_newline();
|
||||||
}
|
}
|
||||||
|
@ -1427,6 +1431,9 @@ void ScriptTextEditor::_edit_option(int p_op) {
|
||||||
case EDIT_TRIM_TRAILING_WHITESAPCE: {
|
case EDIT_TRIM_TRAILING_WHITESAPCE: {
|
||||||
trim_trailing_whitespace();
|
trim_trailing_whitespace();
|
||||||
} break;
|
} break;
|
||||||
|
case EDIT_TRIM_FINAL_NEWLINES: {
|
||||||
|
trim_final_newlines();
|
||||||
|
} break;
|
||||||
case EDIT_CONVERT_INDENT_TO_SPACES: {
|
case EDIT_CONVERT_INDENT_TO_SPACES: {
|
||||||
code_editor->set_indent_using_spaces(true);
|
code_editor->set_indent_using_spaces(true);
|
||||||
convert_indent();
|
convert_indent();
|
||||||
|
@ -2299,6 +2306,7 @@ void ScriptTextEditor::_enable_code_editor() {
|
||||||
edit_menu->get_popup()->add_separator();
|
edit_menu->get_popup()->add_separator();
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_text_completion_query"), EDIT_COMPLETE);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("ui_text_completion_query"), EDIT_COMPLETE);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE);
|
||||||
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_final_newlines"), EDIT_TRIM_FINAL_NEWLINES);
|
||||||
{
|
{
|
||||||
PopupMenu *sub_menu = memnew(PopupMenu);
|
PopupMenu *sub_menu = memnew(PopupMenu);
|
||||||
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES);
|
sub_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES);
|
||||||
|
@ -2484,6 +2492,7 @@ void ScriptTextEditor::register_editor() {
|
||||||
ED_SHORTCUT("script_text_editor/evaluate_selection", TTR("Evaluate Selection"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::E);
|
ED_SHORTCUT("script_text_editor/evaluate_selection", TTR("Evaluate Selection"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::E);
|
||||||
ED_SHORTCUT("script_text_editor/toggle_word_wrap", TTR("Toggle Word Wrap"), KeyModifierMask::ALT | Key::Z);
|
ED_SHORTCUT("script_text_editor/toggle_word_wrap", TTR("Toggle Word Wrap"), KeyModifierMask::ALT | Key::Z);
|
||||||
ED_SHORTCUT("script_text_editor/trim_trailing_whitespace", TTR("Trim Trailing Whitespace"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT | Key::T);
|
ED_SHORTCUT("script_text_editor/trim_trailing_whitespace", TTR("Trim Trailing Whitespace"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::ALT | Key::T);
|
||||||
|
ED_SHORTCUT("script_text_editor/trim_final_newlines", TTR("Trim Final Newlines"), Key::NONE);
|
||||||
ED_SHORTCUT("script_text_editor/convert_indent_to_spaces", TTR("Convert Indent to Spaces"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::Y);
|
ED_SHORTCUT("script_text_editor/convert_indent_to_spaces", TTR("Convert Indent to Spaces"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::Y);
|
||||||
ED_SHORTCUT("script_text_editor/convert_indent_to_tabs", TTR("Convert Indent to Tabs"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::I);
|
ED_SHORTCUT("script_text_editor/convert_indent_to_tabs", TTR("Convert Indent to Tabs"), KeyModifierMask::CMD_OR_CTRL | KeyModifierMask::SHIFT | Key::I);
|
||||||
ED_SHORTCUT("script_text_editor/auto_indent", TTR("Auto Indent"), KeyModifierMask::CMD_OR_CTRL | Key::I);
|
ED_SHORTCUT("script_text_editor/auto_indent", TTR("Auto Indent"), KeyModifierMask::CMD_OR_CTRL | Key::I);
|
||||||
|
|
|
@ -118,6 +118,7 @@ class ScriptTextEditor : public ScriptEditorBase {
|
||||||
EDIT_COMPLETE,
|
EDIT_COMPLETE,
|
||||||
EDIT_AUTO_INDENT,
|
EDIT_AUTO_INDENT,
|
||||||
EDIT_TRIM_TRAILING_WHITESAPCE,
|
EDIT_TRIM_TRAILING_WHITESAPCE,
|
||||||
|
EDIT_TRIM_FINAL_NEWLINES,
|
||||||
EDIT_CONVERT_INDENT_TO_SPACES,
|
EDIT_CONVERT_INDENT_TO_SPACES,
|
||||||
EDIT_CONVERT_INDENT_TO_TABS,
|
EDIT_CONVERT_INDENT_TO_TABS,
|
||||||
EDIT_TOGGLE_COMMENT,
|
EDIT_TOGGLE_COMMENT,
|
||||||
|
@ -228,6 +229,7 @@ public:
|
||||||
virtual Variant get_navigation_state() override;
|
virtual Variant get_navigation_state() override;
|
||||||
virtual void ensure_focus() override;
|
virtual void ensure_focus() override;
|
||||||
virtual void trim_trailing_whitespace() override;
|
virtual void trim_trailing_whitespace() override;
|
||||||
|
virtual void trim_final_newlines() override;
|
||||||
virtual void insert_final_newline() override;
|
virtual void insert_final_newline() override;
|
||||||
virtual void convert_indent() override;
|
virtual void convert_indent() override;
|
||||||
virtual void tag_saved_version() override;
|
virtual void tag_saved_version() override;
|
||||||
|
|
|
@ -436,8 +436,14 @@ void ShaderEditorPlugin::_menu_item_pressed(int p_index) {
|
||||||
int index = shader_tabs->get_current_tab();
|
int index = shader_tabs->get_current_tab();
|
||||||
ERR_FAIL_INDEX(index, shader_tabs->get_tab_count());
|
ERR_FAIL_INDEX(index, shader_tabs->get_tab_count());
|
||||||
TextShaderEditor *editor = edited_shaders[index].shader_editor;
|
TextShaderEditor *editor = edited_shaders[index].shader_editor;
|
||||||
if (editor && editor->get_trim_trailing_whitespace_on_save()) {
|
if (editor) {
|
||||||
editor->trim_trailing_whitespace();
|
if (editor->get_trim_trailing_whitespace_on_save()) {
|
||||||
|
editor->trim_trailing_whitespace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (editor->get_trim_final_newlines_on_save()) {
|
||||||
|
editor->trim_final_newlines();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (edited_shaders[index].shader.is_valid()) {
|
if (edited_shaders[index].shader.is_valid()) {
|
||||||
EditorNode::get_singleton()->save_resource(edited_shaders[index].shader);
|
EditorNode::get_singleton()->save_resource(edited_shaders[index].shader);
|
||||||
|
@ -452,8 +458,14 @@ void ShaderEditorPlugin::_menu_item_pressed(int p_index) {
|
||||||
int index = shader_tabs->get_current_tab();
|
int index = shader_tabs->get_current_tab();
|
||||||
ERR_FAIL_INDEX(index, shader_tabs->get_tab_count());
|
ERR_FAIL_INDEX(index, shader_tabs->get_tab_count());
|
||||||
TextShaderEditor *editor = edited_shaders[index].shader_editor;
|
TextShaderEditor *editor = edited_shaders[index].shader_editor;
|
||||||
if (editor && editor->get_trim_trailing_whitespace_on_save()) {
|
if (editor) {
|
||||||
editor->trim_trailing_whitespace();
|
if (editor->get_trim_trailing_whitespace_on_save()) {
|
||||||
|
editor->trim_trailing_whitespace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (editor->get_trim_final_newlines_on_save()) {
|
||||||
|
editor->trim_final_newlines();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String path;
|
String path;
|
||||||
if (edited_shaders[index].shader.is_valid()) {
|
if (edited_shaders[index].shader.is_valid()) {
|
||||||
|
|
|
@ -288,6 +288,10 @@ void TextEditor::trim_trailing_whitespace() {
|
||||||
code_editor->trim_trailing_whitespace();
|
code_editor->trim_trailing_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEditor::trim_final_newlines() {
|
||||||
|
code_editor->trim_final_newlines();
|
||||||
|
}
|
||||||
|
|
||||||
void TextEditor::insert_final_newline() {
|
void TextEditor::insert_final_newline() {
|
||||||
code_editor->insert_final_newline();
|
code_editor->insert_final_newline();
|
||||||
}
|
}
|
||||||
|
@ -414,6 +418,9 @@ void TextEditor::_edit_option(int p_op) {
|
||||||
case EDIT_TRIM_TRAILING_WHITESAPCE: {
|
case EDIT_TRIM_TRAILING_WHITESAPCE: {
|
||||||
trim_trailing_whitespace();
|
trim_trailing_whitespace();
|
||||||
} break;
|
} break;
|
||||||
|
case EDIT_TRIM_FINAL_NEWLINES: {
|
||||||
|
trim_final_newlines();
|
||||||
|
} break;
|
||||||
case EDIT_CONVERT_INDENT_TO_SPACES: {
|
case EDIT_CONVERT_INDENT_TO_SPACES: {
|
||||||
code_editor->set_indent_using_spaces(true);
|
code_editor->set_indent_using_spaces(true);
|
||||||
convert_indent();
|
convert_indent();
|
||||||
|
@ -641,6 +648,7 @@ TextEditor::TextEditor() {
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_lines"), EDIT_DUPLICATE_LINES);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/duplicate_lines"), EDIT_DUPLICATE_LINES);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_word_wrap"), EDIT_TOGGLE_WORD_WRAP);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_word_wrap"), EDIT_TOGGLE_WORD_WRAP);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_trailing_whitespace"), EDIT_TRIM_TRAILING_WHITESAPCE);
|
||||||
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/trim_final_newlines"), EDIT_TRIM_FINAL_NEWLINES);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_spaces"), EDIT_CONVERT_INDENT_TO_SPACES);
|
||||||
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS);
|
edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_indent_to_tabs"), EDIT_CONVERT_INDENT_TO_TABS);
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ private:
|
||||||
EDIT_PASTE,
|
EDIT_PASTE,
|
||||||
EDIT_SELECT_ALL,
|
EDIT_SELECT_ALL,
|
||||||
EDIT_TRIM_TRAILING_WHITESAPCE,
|
EDIT_TRIM_TRAILING_WHITESAPCE,
|
||||||
|
EDIT_TRIM_FINAL_NEWLINES,
|
||||||
EDIT_CONVERT_INDENT_TO_SPACES,
|
EDIT_CONVERT_INDENT_TO_SPACES,
|
||||||
EDIT_CONVERT_INDENT_TO_TABS,
|
EDIT_CONVERT_INDENT_TO_TABS,
|
||||||
EDIT_MOVE_LINE_UP,
|
EDIT_MOVE_LINE_UP,
|
||||||
|
@ -133,6 +134,7 @@ public:
|
||||||
virtual void set_executing_line(int p_line) override;
|
virtual void set_executing_line(int p_line) override;
|
||||||
virtual void clear_executing_line() override;
|
virtual void clear_executing_line() override;
|
||||||
virtual void trim_trailing_whitespace() override;
|
virtual void trim_trailing_whitespace() override;
|
||||||
|
virtual void trim_final_newlines() override;
|
||||||
virtual void insert_final_newline() override;
|
virtual void insert_final_newline() override;
|
||||||
virtual void convert_indent() override;
|
virtual void convert_indent() override;
|
||||||
virtual void ensure_focus() override;
|
virtual void ensure_focus() override;
|
||||||
|
|
|
@ -756,6 +756,7 @@ void TextShaderEditor::_apply_editor_settings() {
|
||||||
code_editor->update_editor_settings();
|
code_editor->update_editor_settings();
|
||||||
|
|
||||||
trim_trailing_whitespace_on_save = EDITOR_GET("text_editor/behavior/files/trim_trailing_whitespace_on_save");
|
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");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextShaderEditor::_show_warnings_panel(bool p_show) {
|
void TextShaderEditor::_show_warnings_panel(bool p_show) {
|
||||||
|
@ -920,6 +921,10 @@ void TextShaderEditor::save_external_data(const String &p_str) {
|
||||||
trim_trailing_whitespace();
|
trim_trailing_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (trim_final_newlines_on_save) {
|
||||||
|
trim_final_newlines();
|
||||||
|
}
|
||||||
|
|
||||||
apply_shaders();
|
apply_shaders();
|
||||||
|
|
||||||
Ref<Shader> edited_shader = code_editor->get_edited_shader();
|
Ref<Shader> edited_shader = code_editor->get_edited_shader();
|
||||||
|
@ -946,6 +951,10 @@ void TextShaderEditor::trim_trailing_whitespace() {
|
||||||
code_editor->trim_trailing_whitespace();
|
code_editor->trim_trailing_whitespace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextShaderEditor::trim_final_newlines() {
|
||||||
|
code_editor->trim_final_newlines();
|
||||||
|
}
|
||||||
|
|
||||||
void TextShaderEditor::validate_script() {
|
void TextShaderEditor::validate_script() {
|
||||||
code_editor->_validate_script();
|
code_editor->_validate_script();
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,6 +176,7 @@ class TextShaderEditor : public MarginContainer {
|
||||||
uint32_t dependencies_version = 0xFFFFFFFF;
|
uint32_t dependencies_version = 0xFFFFFFFF;
|
||||||
|
|
||||||
bool trim_trailing_whitespace_on_save;
|
bool trim_trailing_whitespace_on_save;
|
||||||
|
bool trim_final_newlines_on_save;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
@ -189,6 +190,7 @@ protected:
|
||||||
public:
|
public:
|
||||||
bool was_compilation_successful() const { return compilation_success; }
|
bool was_compilation_successful() const { return compilation_success; }
|
||||||
bool get_trim_trailing_whitespace_on_save() const { return trim_trailing_whitespace_on_save; }
|
bool get_trim_trailing_whitespace_on_save() const { return trim_trailing_whitespace_on_save; }
|
||||||
|
bool get_trim_final_newlines_on_save() const { return trim_final_newlines_on_save; }
|
||||||
void apply_shaders();
|
void apply_shaders();
|
||||||
void ensure_select_current();
|
void ensure_select_current();
|
||||||
void edit(const Ref<Shader> &p_shader);
|
void edit(const Ref<Shader> &p_shader);
|
||||||
|
@ -196,6 +198,7 @@ public:
|
||||||
void goto_line_selection(int p_line, int p_begin, int p_end);
|
void goto_line_selection(int p_line, int p_begin, int p_end);
|
||||||
void save_external_data(const String &p_str = "");
|
void save_external_data(const String &p_str = "");
|
||||||
void trim_trailing_whitespace();
|
void trim_trailing_whitespace();
|
||||||
|
void trim_final_newlines();
|
||||||
void validate_script();
|
void validate_script();
|
||||||
bool is_unsaved() const;
|
bool is_unsaved() const;
|
||||||
void tag_saved_version();
|
void tag_saved_version();
|
||||||
|
|
Loading…
Reference in New Issue