| 105 | } |
| 106 | |
| 107 | void TextEditor::set_edited_resource(const Ref<Resource> &p_res) { |
| 108 | ERR_FAIL_COND(edited_res.is_valid()); |
| 109 | ERR_FAIL_COND(p_res.is_null()); |
| 110 | |
| 111 | edited_res = p_res; |
| 112 | |
| 113 | Ref<TextFile> text_file = edited_res; |
| 114 | if (text_file.is_valid()) { |
| 115 | code_editor->get_text_editor()->set_text(text_file->get_text()); |
| 116 | } |
| 117 | |
| 118 | Ref<JSON> json_file = edited_res; |
| 119 | if (json_file.is_valid()) { |
| 120 | code_editor->get_text_editor()->set_text(json_file->get_parsed_text()); |
| 121 | } |
| 122 | |
| 123 | code_editor->get_text_editor()->clear_undo_history(); |
| 124 | code_editor->get_text_editor()->tag_saved_version(); |
| 125 | |
| 126 | emit_signal(SNAME("name_changed")); |
| 127 | code_editor->update_line_and_column(); |
| 128 | } |
| 129 | |
| 130 | void TextEditor::enable_editor(Control *p_shortcut_context) { |
| 131 | if (editor_enabled) { |
no test coverage detected