Repository: godot
Issue: Appending to a Node's array through an EditorScript doesn't save the changes to the scene file
Labels: bug,topic:gdscript,topic:editor

### Tested versions

 - Reproducible in v4.3.stable.official [77dcf97d8]

### System information

Godot v4.3.stable - Windows 10.0.19045 - Vulkan (Mobile) - dedicated NVIDIA GeForce GTX 1070 (NVIDIA; 30.0.14.7141) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)

### Issue description

After running an EditorScript that appends to a Node's array, it does not include the new value of the array in the saved scene file.

I have found that the workaround is to use a local variable array in the EditorScript and assign that array as a whole, rather than call .append() directly on the Node's array, so this has something to do with using .append()

This won't work:
```gdscript
for i in range(0, 5):
	current_map.counted_ints.append(i)
```

This will be fine:
```gdscript
var temp:Array[int] = []
for i in range(0, 5):
	temp.append(i)
current_map.counted_ints = temp
```

I notice also that the "revert" icon appears will show up when assigning the whole array, but it won't show up on an array that has been appended.

If you play the game at this point, the value will return to its "pre-appended" value from before you ran the EditorScript. I guess because those changes haven't been saved to the scene file.

If you modify the array in the editor, it will now save, and the revert icon appears, but pressing the revert button reverts to the post-appended value, and saving now will make it disappear from the scene file again.

### Steps to reproduce

Open the array_test scene or create a 3D scene and attach the array_node.gd script to the root node

Contents of array_node.gd (also in project file)
```gdscript
extends Node3D
class_name ArrayNode

@export var counted_ints:Array[int]

@export var assigned_ints:Array[int]
```

Then go to the array_test.gd and run it as an EditorScript

Contents of array_test.gd (also in project file):

```gdscript
@tool
extends EditorScript

func _run() -> void:
	var current_map:ArrayNode = get_scene() as ArrayNode
	if current_map == null:
		return
	
	current_map.counted_ints = []
	for i in range(0, 5):
		current_map.counted_ints.append(i) # these changes will not be saved to the .tscn file
	
	current_map.assigned_ints = [0, 1, 2, 3, 4] # this will be saved to the .tscn file
```

After running that, save the scene. The value for assigned_ints will appear in the scene file but the value for counted_ints will not.

Contents of scene file after saving:

```
[gd_scene load_steps=2 format=3 uid="uid://ld3p44qg5h4o"]

[ext_resource type="Script" path="res://array_node.gd" id="1_l8tlx"]

[node name="ArrayTest" type="Node3D"]
script = ExtResource("1_l8tlx")
assigned_ints = Array[int]([0, 1, 2, 3, 4])
```

Also note that assigned_ints will have a revert button and counted_ints will not. If you modify counted_ints in the editor, the revert button will appear and pressing it will revert to the post-appended version. But playing the game or leaving Godot and returning will revert to the pre-appended version, because the post-appended version hasn't been saved to the scene file.

### Minimal reproduction project (MRP)

[array_append_editorscript.zip](https://github.com/user-attachments/files/17822731/array_append_editorscript.zip)