1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-31 18:41:20 +00:00

Ensure correct unlocking of script editor history

This commit is contained in:
HolonProduction
2025-12-05 12:21:03 +01:00
parent 78d91947f6
commit 31307ce856
3 changed files with 10 additions and 1 deletions

View File

@@ -676,7 +676,6 @@ void ScriptEditor::_save_history() {
void ScriptEditor::_save_previous_state(Dictionary p_state) {
if (lock_history) {
// Done as a result of a deferred call triggered by set_edit_state().
lock_history = false;
return;
}
@@ -3853,6 +3852,10 @@ void ScriptEditor::_update_selected_editor_menu() {
}
}
void ScriptEditor::_unlock_history() {
lock_history = false;
}
void ScriptEditor::_update_history_pos(int p_new_pos) {
Node *n = tab_container->get_current_tab_control();
@@ -3872,6 +3875,10 @@ void ScriptEditor::_update_history_pos(int p_new_pos) {
if (seb) {
lock_history = true;
seb->set_edit_state(history[history_pos].state);
// `set_edit_state()` can modify the caret position which might trigger a
// request to save the history. Since `TextEdit::caret_changed` is emitted
// deferred, we need to defer unlocking of the history as well.
callable_mp(this, &ScriptEditor::_unlock_history).call_deferred();
seb->ensure_focus();
Ref<Script> scr = seb->get_edited_resource();