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

.gd files changed unexpectedly on running a project #56510

Open
Tracked by #40488
velteyn opened this issue Jan 5, 2022 · 5 comments
Open
Tracked by #40488

.gd files changed unexpectedly on running a project #56510

velteyn opened this issue Jan 5, 2022 · 5 comments

Comments

@velteyn
Copy link

velteyn commented Jan 5, 2022

Godot version

3.4.2

System information

Windows 10 GLES3

Issue description

I'm learning Godot and I downloaded an example project from GitHub
https://github.com/CadanoX/Godot-Slot-Machine

After I run it it gives me the error: "mixed tabs and spacing in indentation." And it does not start.
I see that the original files from GitHub are indented using spaces only.
When I RUN the project it seems that Godot adds some tabs under the ifs autonomously.
I think that a program don't have the rights to change files autonomously but only to give errors if the file is not correct..

Steps to reproduce

1)Download the Github project as a zip
https://github.com/CadanoX/Godot-Slot-Machine
2)Open SlotMachine.gd with notepad++ and enable "display Spaces and tabulations"
As you can see the file is paced indented only, leave it opened
3) Import the project in godot
4) Run it
5) Project don't start but gives "Mixed tabs and spacing in indentation" error
6) Notepad++ states that the files have been modified and ask to reload it
7) Reload the file and you can see that Godot modified the file..

According to me Godot should only tell the User that something is wrong but should not touch the files on loading.
I tried fixing the files but Godot keeps changing them. It only likes tabs indentation and in that case it leaves them untouched..

Minimal reproduction project

https://github.com/CadanoX/Godot-Slot-Machine

@velteyn velteyn changed the title .gd files changed unexpectedly on running the a project .gd files changed unexpectedly on running a project Jan 5, 2022
@akien-mga
Copy link
Member

This happens because Godot's default Editor Settings are:

  • text_editor/indent/convert_indent_on_save: enabled
  • text_editor/indent/type: Tabs
  • text_editor/indent/size: 4

So it automatically converts 4 spaces to one tab.

You can solve it by disabling convert_indent_on_save, or by changing the indent type to 2 Spaces to match that project's convention.

@akien-mga
Copy link
Member

@Paulb23 Do you think we could make Convert Indent on Save cleverer in such cases to avoid breakage?

Or should we disable it by default (and maybe add a "Strip Trailing Whitespace" instead that could be enabled by default).

Also related: godotengine/godot-proposals#3525, which would make Convert Indent on Save mostly irrelevant (never got to finish my implementation)

@Calinou
Copy link
Member

Calinou commented Jan 5, 2022

Or should we disable it by default (and maybe add a "Strip Trailing Whitespace" instead that could be enabled by default).

This option already exists, but it's disabled by default. Enabling it by default makes sense, but it can reduce productivity due to it always trimming whitespace on the line the cursor is currently on. See also godotengine/godot-proposals#3229.

@RobertoMaurizzi
Copy link

RobertoMaurizzi commented Aug 7, 2022

Just got bitten by this after upgrading to 3.5 from 3.4.5...
I'm at a loss here: shouldn't it convert ALL spaces to tabs, or ALL tabs to spaces? Why some tabs (default) are apparently randomly added/replaced but only on some lines, if the setting is called convert_indent_on_save?

@Juksefantomet
Copy link

Adding to this issue, this is breaking .github/workflows/*.yml files when saving / reloading / opening projects.

The yml indentation is broken by godot as it doesn't not allow you to select "preserve original", it's only spaces or tabs.

Additionally this would be a lot easier to handle if we had a "ignore files of type: x,y,z" where you can instruct godot on a project base to ignore files of X types completely.

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

5 participants