godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.83k stars 20.95k forks source link

Renaming .txt file to .glsl while it is open in the editor has unpredictable results #71401

Open JohanAR opened 1 year ago

JohanAR commented 1 year ago

Godot version

v4.0.beta.custom_build [3c9bf4bc2]

System information

Fedora 36 KDE, RTX 3080

Issue description

If I create a TextFile in Godot and change the file extension to .glsl I get different behaviour if the file was open in the editor at the time of renaming.

Steps to reproduce

First attempt, file not open when renaming:

  1. Create a TextFile in Godot and name it "test1.txt"
  2. Right click it in the FileSystem dock and rename it to "test1.glsl"
  3. Double click the file -> ShaderFile tab opens.
  4. In a script, both load and preload of the file produces a Resource / RDShaderFile

Everything works as expected.

Second attempt, file open when renaming:

  1. Create a TextFile in Godot and name it "test2.txt"
  2. Double click the file to open it in the Godot editor.
  3. Right click it in the FileSystem dock and rename it to "test2.glsl"
  4. Close the file in the Godot editor.
  5. Double click the file -> It opens in the editor.
  6. In a script, load the file produces a Resource / RDShaderFile
  7. In a script, preload-ing the file produces a TextFile

Minimal reproduction project

I think it's easier to see the strange behaviour by reproducing the steps in the editor.

npip99 commented 10 months ago

I'm not sure if my issue is related; But, when I open test.glsl to edit using the built-in Godot text editor, then load("test.glsl") gives me a TextFile, even when the .import says RDShaderFile. When I close the file in the built-in Godot text editor, it fixes.

Was a little weird to figure out, but now it's no issue. I just hit "close" when I'm done editing and the code works.