Godot: Mixed tabs and spaces no longer supported for multiline declarations

Created on 29 Jul 2019  路  12Comments  路  Source: godotengine/godot

Godot version:
6c9ccf18f

Issue description:
GDScript files which contain mixed tabs and spaces in multiline definitions (for example, to align dictionaries or arrays) are now considered a hard error when before they were ignored. This can (for example) break plugins when migrating.

bug gdscript

Most helpful comment

It should only error when the indentation has syntactic meaning, like in a code block. So that last screenshot is a valid error for example, the comment is badly indented in its scope.

But for array/dict declarations and statements wrapped over multiple lines, freestyle should be allowed (even if mixing tabs and spaces is ewww, but still not a reason for a syntax error if it can't be a source of bugs).

All 12 comments

Can you give examples of such multiline definitions?

can-do.

image

I had to replace 3 spaces on lines 21 and 22 to a tab for the script to pass the current parser, but it now looks ugly. This is just a simple example; more complicated ones would obviously have more instances of this necessary to alignment if nesting becomes involved (such as with dictionaries) and the declaration far exceeded 80 characters (or whatever the canonical convention is supposed to be now).

Another few examples flagged in my current codebase:
image
image
image

Mixing tabs and spaces _should_ error. The convention commonly seen for continuing lines is two tabs anyways.

It should only error when the indentation has syntactic meaning, like in a code block. So that last screenshot is a valid error for example, the comment is badly indented in its scope.

But for array/dict declarations and statements wrapped over multiple lines, freestyle should be allowed (even if mixing tabs and spaces is ewww, but still not a reason for a syntax error if it can't be a source of bugs).

This can (for example) break plugins when migrating.

True, I had to come up with custom indentation fixes in order to continue using some plugins, see bitwes/Gut#126 for instance. Also noticed this in godot-logger.

Talking about plugins, consider making an ability to ignore indentation inconsistencies for "third-party" stuff or custom folders, as proposed in #28232 to ignore warnings in GDScript. Alternatively, one could make indentation inconsistency error to be treated as a warning optionally (per project or folder). Warnings can be turned on to be treated as errors anytime, though you can't make a single warning to be treated as an error unfortunately.

@akien-mga Also for long function calls that one may want to break the parentheses into several lines.

@Skaruts This can already be done using only tabs (or spaces), for instance:

some_function_call(
        123, "hello", 456)

some_function_call(
        123,
        "hello",
        456
)

The GDScript style guide advises using two tabs to distinguish line continuation indents from regular code blocks.

@Calinou Yea, sometimes I do them like that (the 2nd one), but usually with the ) indented one more (because the two tabs on their own don't make the relationship between the lines immediately stand out to me).

But there are cases where doing them like the example below helps me visualize things better. The code looks clearer to my eyes this way.

igm.draw_linestrip( 
                    [   
                        Vector3(), 
                        Vector3(core.grid_size, 0,  0),
                        Vector3(core.grid_size, 0, core.grid_size), 
                        Vector3(0 , 0, core.grid_size),
                        Vector3()
                    ], 
                    "ig_grid_bounds"     # <-- second function parameter
                  ) 

(Had to use spaces there just to align things properly, because github. The original uses tabs.)
I usually need spaces to align those.

Also, I realize that could be simplified by building the array separately, but I don't remember where I would have a better example right now.

Who program in other languages knows that "Tab" is used and always was to identify code, now in cases of use of matrix or similar even to think, but still, what is the justification?

What is the justification? Just say it's like that and that's it, no real advantage?

Why don't you come back and release the TAB?
Removing Godot's TAB usage is very wrong, all programming languages coexist well, why did Godot decide to change that?

What is the justification for [issued described and labelled as a bug]?

It's a bug.

Was this page helpful?
0 / 5 - 0 ratings