Godot version: 3.0-rc2. Occurs on 3.0-rc1 as well. I imagine it occurs on other versions as well, but these are the only two versions I have ever used.
OS/device including version: Debian Buster, 64-bit
Issue description: The Godot editor modifies my scene (tscn) files, adding and removing index="0"
from the root node frequently. This indicates which scene tab is open in the editor. Similarly, it modifies the same files with _sections_unfolded =
for any sections I unfold on any node.
Why is this an issue? Well, I use version control, obviously. I do modify tscn files, so I must be able to track them. However, on top of those changes are these frequent changes of these two lines. This is either a pain to deal with to prevent committing, or can even lead to unnecessary merge conflicts.
Steps to reproduce:
git diff
. You will see the clutter.Minimal reproduction project: Literally any project with two scenes. Here's one I made, with a .git folder that was clean before I expanded some sections. Running git diff shows the clutter.
godot-issue.zip
I wrote a quick and dirty Python script to remove the editor state information from scene files: clean_editor_state.py
I put this on my project root and run it before every commit. Not the best solution, but it works for now. I hope this issue gets resolved soon though. :)
This is awesome, thanks! Maybe I could put that in a git hook too. I'll look into it when I get home and update what I figure out.
In additon to _sections_unfolded
and the current active tab, there is also the editor/display_folded
property that keeps changing when you fold a node tree in a scene.
It'd be nice if this information could be saved in a separate file (perhaps something like .gdeditor
?), which we could easily ignore in version control.
I updated my script, it now removes editor/display_folded
as well.
I added rect_clip_content
cause i get those a lot too:
elif line.startswith('rect_clip_content = false'):
continue
Is there any progress on solving this? Ideally this information shouldn't be stored in the project files at all, perhaps ~/.config/godot
would be better.
I updated my script, it now removes
editor/display_folded
as well.
editor/display_folded
can also be the only property of some node, just like _sections_unfolded
. You need to remove the blank line there as well.
Based on your script, I wrote the following:
#!/usr/bin/env python3
import os
def remove_state(lines):
for line in lines:
if line.startswith('_sections_unfolded'):
continue
elif line.startswith('editor/display_folded'):
continue
elif line.startswith('[node') and 'parent=' not in line:
yield line.replace(' index="0"', '')
else:
yield line
def remove_double_newlines(lines):
yielded_newline = False
for line in lines:
if line == '\n':
if yielded_newline:
continue
yielded_newline = True
yield line
else:
yielded_newline = False
yield line
excluded_directories = {
'.git',
'.import',
}
included_extensions = {
'.tres',
'.tscn',
}
for root_path, directories, files in os.walk('.'):
directories[:] = [d for d in directories if d not in excluded_directories]
for file in files:
if not any(file.endswith(extension) for extension in included_extensions):
continue
path = os.path.join(root_path, file)
with open(path, 'r') as f:
lines = f.readlines()
with open(path, 'w') as f:
f.writelines(remove_double_newlines(remove_state(lines)))
Fixed by e6473421.
Most helpful comment
Is there any progress on solving this? Ideally this information shouldn't be stored in the project files at all, perhaps
~/.config/godot
would be better.