Convert indent on save
This commit is contained in:
parent
84bca4e72f
commit
c59bd79e02
4 changed files with 47 additions and 0 deletions
|
@ -530,6 +530,15 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
|
|||
if (trim_trailing_whitespace_on_save) {
|
||||
se->trim_trailing_whitespace();
|
||||
}
|
||||
|
||||
if (convert_indent_on_save) {
|
||||
if (use_space_indentation) {
|
||||
se->convert_indent_to_spaces();
|
||||
} else {
|
||||
se->convert_indent_to_tabs();
|
||||
}
|
||||
}
|
||||
|
||||
editor->save_resource(script);
|
||||
se->tag_saved_version();
|
||||
}
|
||||
|
@ -795,12 +804,28 @@ void ScriptEditor::_menu_option(int p_option) {
|
|||
|
||||
if (trim_trailing_whitespace_on_save)
|
||||
current->trim_trailing_whitespace();
|
||||
|
||||
if (convert_indent_on_save) {
|
||||
if (use_space_indentation) {
|
||||
current->convert_indent_to_spaces();
|
||||
} else {
|
||||
current->convert_indent_to_tabs();
|
||||
}
|
||||
}
|
||||
editor->save_resource(current->get_edited_script());
|
||||
|
||||
} break;
|
||||
case FILE_SAVE_AS: {
|
||||
|
||||
current->trim_trailing_whitespace();
|
||||
|
||||
if (convert_indent_on_save) {
|
||||
if (use_space_indentation) {
|
||||
current->convert_indent_to_spaces();
|
||||
} else {
|
||||
current->convert_indent_to_tabs();
|
||||
}
|
||||
}
|
||||
editor->push_item(current->get_edited_script()->cast_to<Object>());
|
||||
editor->save_resource_as(current->get_edited_script());
|
||||
|
||||
|
@ -1483,6 +1508,14 @@ void ScriptEditor::save_all_scripts() {
|
|||
se->trim_trailing_whitespace();
|
||||
}
|
||||
|
||||
if (convert_indent_on_save) {
|
||||
if (use_space_indentation) {
|
||||
se->convert_indent_to_spaces();
|
||||
} else {
|
||||
se->convert_indent_to_tabs();
|
||||
}
|
||||
}
|
||||
|
||||
Ref<Script> script = se->get_edited_script();
|
||||
if (script.is_valid())
|
||||
se->apply_code();
|
||||
|
@ -2163,6 +2196,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
|
|||
|
||||
edit_pass = 0;
|
||||
trim_trailing_whitespace_on_save = false;
|
||||
convert_indent_on_save = false;
|
||||
use_space_indentation = false;
|
||||
|
||||
ScriptServer::edit_request_func = _open_script_request;
|
||||
}
|
||||
|
|
|
@ -91,6 +91,8 @@ public:
|
|||
virtual void set_edit_state(const Variant &p_state) = 0;
|
||||
virtual void goto_line(int p_line, bool p_with_error = false) = 0;
|
||||
virtual void trim_trailing_whitespace() = 0;
|
||||
virtual void convert_indent_to_spaces() = 0;
|
||||
virtual void convert_indent_to_tabs() = 0;
|
||||
virtual void ensure_focus() = 0;
|
||||
virtual void tag_saved_version() = 0;
|
||||
virtual void reload(bool p_soft) = 0;
|
||||
|
@ -252,6 +254,8 @@ class ScriptEditor : public VBoxContainer {
|
|||
void _res_saved_callback(const Ref<Resource> &p_res);
|
||||
|
||||
bool trim_trailing_whitespace_on_save;
|
||||
bool use_space_indentation;
|
||||
bool convert_indent_on_save;
|
||||
|
||||
void _trim_trailing_whitespace(TextEdit *tx);
|
||||
|
||||
|
|
|
@ -2163,6 +2163,12 @@ void VisualScriptEditor::goto_line(int p_line, bool p_with_error) {
|
|||
void VisualScriptEditor::trim_trailing_whitespace() {
|
||||
}
|
||||
|
||||
void VisualScriptEditor::convert_indent_to_spaces() {
|
||||
}
|
||||
|
||||
void VisualScriptEditor::convert_indent_to_tabs() {
|
||||
}
|
||||
|
||||
void VisualScriptEditor::ensure_focus() {
|
||||
|
||||
graph->grab_focus();
|
||||
|
|
|
@ -240,6 +240,8 @@ public:
|
|||
virtual void set_edit_state(const Variant &p_state);
|
||||
virtual void goto_line(int p_line, bool p_with_error = false);
|
||||
virtual void trim_trailing_whitespace();
|
||||
virtual void convert_indent_to_spaces();
|
||||
virtual void convert_indent_to_tabs();
|
||||
virtual void ensure_focus();
|
||||
virtual void tag_saved_version();
|
||||
virtual void reload(bool p_soft);
|
||||
|
|
Loading…
Reference in a new issue