Skip to content

Commit 835383d

Browse files
committed
Fix region folding not loading properly
1 parent 9283328 commit 835383d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

editor/script/script_text_editor.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ void ScriptTextEditor::enable_editor(Control *p_shortcut_context) {
184184

185185
_validate_script();
186186

187+
if (pending_state != Variant()) {
188+
code_editor->set_edit_state(pending_state);
189+
pending_state = Variant();
190+
}
191+
187192
if (p_shortcut_context) {
188193
for (int i = 0; i < edit_hb->get_child_count(); ++i) {
189194
Control *c = cast_to<Control>(edit_hb->get_child(i));
@@ -704,11 +709,19 @@ bool ScriptTextEditor::is_unsaved() {
704709
}
705710

706711
Variant ScriptTextEditor::get_edit_state() {
712+
if (pending_state != Variant()) {
713+
return pending_state;
714+
}
707715
return code_editor->get_edit_state();
708716
}
709717

710718
void ScriptTextEditor::set_edit_state(const Variant &p_state) {
711-
code_editor->set_edit_state(p_state);
719+
if (editor_enabled) {
720+
code_editor->set_edit_state(p_state);
721+
} else {
722+
// The editor is not fully initialized, so the state can't be loaded properly.
723+
pending_state = p_state;
724+
}
712725

713726
Dictionary state = p_state;
714727
if (state.has("syntax_highlighter")) {

editor/script/script_text_editor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class ScriptTextEditor : public ScriptEditorBase {
6262
RichTextLabel *errors_panel = nullptr;
6363

6464
Ref<Script> script;
65+
Variant pending_state;
6566
bool script_is_valid = false;
6667
bool editor_enabled = false;
6768

0 commit comments

Comments
 (0)