Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move active tab and sections to a separate file #15982

Closed
CosineP opened this issue Jan 22, 2018 · 9 comments
Closed

Move active tab and sections to a separate file #15982

CosineP opened this issue Jan 22, 2018 · 9 comments

Comments

@CosineP
Copy link

CosineP commented Jan 22, 2018

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:

  • Start with a godot project with a clean git
  • Open a project with the editor
  • Make a different scene tab active, and expand a section on any node
  • Save that scene
  • Run 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

@mmermerkaya
Copy link

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. :)

@CosineP
Copy link
Author

CosineP commented Feb 28, 2018

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.

@voithos
Copy link
Contributor

voithos commented May 28, 2018

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.

@mmermerkaya
Copy link

I updated my script, it now removes editor/display_folded as well.

@CosineP
Copy link
Author

CosineP commented Jun 15, 2018

I added rect_clip_content cause i get those a lot too:

            elif line.startswith('rect_clip_content = false'):
                continue

@aaronfranke
Copy link
Member

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.

@Hendrikto
Copy link
Contributor

Hendrikto commented Oct 11, 2018

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)))

@aaronfranke
Copy link
Member

See also #20994

@akien-mga
Copy link
Member

Fixed by e647342.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants