godotengine / godotengine/godot

Scripts in Resources fail to save properly

Open
#113,166 5 comments 2 reactions 0 assignees View on GitHub
bug needs testing topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in v4.5.1.stable.official [f62fdbde1]

### System information

Godot v4.5.1.stable - Windows 10 (build 19045) - Multi-window, 2 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 2060 (NVIDIA; 32.0.15.7242) - AMD Ryzen 5 3600X 6-Core Processor (12 threads) - 31.93 GiB memory

### Issue description

When creating a script on a resource that is not stored in a separate .gd file, then after editing it and hitting CTRL+S, it will keep the unsaved indicator (the (\*) at the end of the filename). Trying to Close it will give the confirm dialog with (Save/Cancel/Discard), but neither selecting Save nor Cancel will actually save the changes to the script.
While in this state (still open with (\*) indicator) if project is closed or "Reload Current Project" is selected then one will get stuck with the unsaved changes confirm dialog, and pressing "Save & Reload" will just make it re-appear again and again.

Image

Things that DO make the script save:
using Save the script from the context menu of the script view or pressing the corresponding shortcut Ctrl+Alt+S.

Image

Or anytime the resource itself is saved, like selecting save from the inspector while the resource is open.

### Steps to reproduce

1. open a scene (for some reason necessary, issue does not happen if no scene has been opened since starting godot)

Image

2. Create new Resource

Image

3. Create a new GDScript object for the Resources script property

Image

4. write something in there like `extends Resource` to cause a change in the script

5. hit Ctrl + S (the name in the open script view list should have a (*) next to it now)Image
6. Try various things like closing it in the script view or pressing Reload Current Project
7. When checking the resource file with an external text editor it can be seen that the changes to the script are not saved

### Minimal reproduction project (MRP)

The steps are easy to do from an empty project but one can also use the bug.zip from this issue: https://github.com/godotengine/godot/issues/101991#issuecomment-2613203826

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue using the listed steps: open a scene, create a Resource with an embedded GDScript, edit it, and press Ctrl+S. Compare the regular save path with the script-view context-menu save, then verify that the resource file contains the changes and that closing or reloading no longer repeats the unsaved-changes dialog.

Written by the indexing model from the issue text.

Assessment

Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.