We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c48d445 commit bdedca2Copy full SHA for bdedca2
1 file changed
addons/GDQuest_GDScript_formatter/plugin.gd
@@ -234,7 +234,12 @@ func _on_resource_saved(saved_resource: Resource) -> void:
234
235
script.source_code = formatted_code
236
ResourceSaver.save(script)
237
- script.reload()
+ # The argument (keep_state parameter) tells Godot to try to preserve the
238
+ # state of the script instance, like static variables. Without this,
239
+ # attempting to reload tool scripts will fail with an error because they
240
+ # are already instantiated in the editor and instantiated scripts are
241
+ # not allowed to force reload without unloading first.
242
+ script.reload(true)
243
244
var script_editor := EditorInterface.get_script_editor()
245
var open_script_editors := script_editor.get_open_script_editors()
0 commit comments