-
-
Notifications
You must be signed in to change notification settings - Fork 22
Bitwise operations not allowed to be split across lines #212
Copy link
Copy link
Open
Description
GDScript allows you to split an expression across multiple lines if it's enclosed in parentheses. However, if the expression is a sequence of binary bitwise operations, GDScript-formatter won't allow this and will reformat it to a single line. This is especially annoying if you have a max line length.
The same thing works fine with logical and arithmetic operators. It also works fine if you use \ to escape newlines, but at least personally I prefer using parentheses over newline escapes wherever possible.
Example script:
extends Mesh
@warning_ignore_start("UNUSED_VARIABLE")
func foo() -> void:
# allowed by formatter
var logical_and := (
ARRAY_FORMAT_NORMAL &&
ARRAY_FORMAT_TANGENT &&
ARRAY_FORMAT_TEX_UV &&
ARRAY_FORMAT_INDEX
)
# allowed by formatter
var arithmetic_add := (
ARRAY_FORMAT_NORMAL +
ARRAY_FORMAT_TANGENT +
ARRAY_FORMAT_TEX_UV +
ARRAY_FORMAT_INDEX
)
# try to format the below statements like the ones above -- formatter will undo it
var bitwise_or := (ARRAY_FORMAT_NORMAL | ARRAY_FORMAT_TANGENT | ARRAY_FORMAT_TEX_UV | ARRAY_FORMAT_INDEX)
var bitwise_and := (ARRAY_FORMAT_NORMAL & ARRAY_FORMAT_TANGENT & ARRAY_FORMAT_TEX_UV & ARRAY_FORMAT_INDEX)
# this is also allowed
var bitwise_with_escapes := ARRAY_FORMAT_NORMAL & \
ARRAY_FORMAT_TANGENT & \
ARRAY_FORMAT_TEX_UV & \
ARRAY_FORMAT_INDEX
(reproduced with the VS Code extension)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels