You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Optimized ScriptEditor initialization when many scripts are loaded
This change avoids the editor to freeze for several seconds when a project with lots of scripts is loaded in the editor. It focuses on a few heavy operations previously executed on all previously loaded scripts: - Initialize script resource (script validation/parsing) only on focus - ScriptTextEditor: code editor and edit menu are added to the scene only on focus - Add to recent scripts only when opening new scripts (load/save scene metadata)
This commit is contained in:
@@ -164,8 +164,7 @@ String TextEditor::get_name() {
|
||||
}
|
||||
|
||||
Ref<Texture> TextEditor::get_icon() {
|
||||
|
||||
return EditorNode::get_singleton()->get_object_icon(text_file.operator->(), "");
|
||||
return EditorNode::get_singleton()->get_object_icon(text_file.ptr(), "");
|
||||
}
|
||||
|
||||
RES TextEditor::get_edited_resource() const {
|
||||
@@ -173,7 +172,8 @@ RES TextEditor::get_edited_resource() const {
|
||||
}
|
||||
|
||||
void TextEditor::set_edited_resource(const RES &p_res) {
|
||||
ERR_FAIL_COND(!text_file.is_null());
|
||||
ERR_FAIL_COND(text_file.is_valid());
|
||||
ERR_FAIL_COND(p_res.is_null());
|
||||
|
||||
text_file = p_res;
|
||||
|
||||
@@ -185,6 +185,16 @@ void TextEditor::set_edited_resource(const RES &p_res) {
|
||||
code_editor->update_line_and_column();
|
||||
}
|
||||
|
||||
void TextEditor::enable_editor() {
|
||||
if (editor_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
editor_enabled = true;
|
||||
|
||||
_load_theme_settings();
|
||||
}
|
||||
|
||||
void TextEditor::add_callback(const String &p_function, PoolStringArray p_args) {
|
||||
}
|
||||
|
||||
@@ -282,6 +292,8 @@ void TextEditor::set_edit_state(const Variant &p_state) {
|
||||
_change_syntax_highlighter(idx);
|
||||
}
|
||||
}
|
||||
|
||||
ensure_focus();
|
||||
}
|
||||
|
||||
void TextEditor::trim_trailing_whitespace() {
|
||||
@@ -361,15 +373,6 @@ void TextEditor::clear_edit_menu() {
|
||||
memdelete(edit_hb);
|
||||
}
|
||||
|
||||
void TextEditor::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_READY:
|
||||
_load_theme_settings();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TextEditor::_edit_option(int p_op) {
|
||||
TextEdit *tx = code_editor->get_text_edit();
|
||||
|
||||
@@ -624,6 +627,8 @@ void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is
|
||||
}
|
||||
|
||||
TextEditor::TextEditor() {
|
||||
editor_enabled = false;
|
||||
|
||||
code_editor = memnew(CodeTextEditor);
|
||||
add_child(code_editor);
|
||||
code_editor->add_constant_override("separation", 0);
|
||||
|
||||
Reference in New Issue
Block a user