Skip to content

Code lost on multi-line ternary expressions with \ continuations #291

Description

@portlek

Description:
The formatter incorrectly breaks multi-line ternary expressions (true if condition else false) that use line continuation (\). Instead of preserving the expression on a single logical line, it splits the tokens across multiple lines in a way that produces invalid syntax.

Input:

func _test() -> void:
    var test: bool = true \
        if not false \
        else false

Output (broken):

func _test() -> void:
    var test: bool = true
    \
     if
    not false \

Expected:
The formatter should preserve the ternary expression on a single logical line, either as-is or reformatted in a way that maintains valid GDScript syntax.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions