Skip to content

Ternary expressions without line continuations still break on multiline else clause #293

Description

@JonRoosevelt

Description

0.22.1 fixed ternaries with \ continuations (#291), but the same bug still occurs when the ternary has no \ continuations but the else argument spans multiple lines.

Input

func _input(event):
    var pitch_input = Input.get_axis("ui_up", "ui_down") if invert_pitch else Input.get_axis(
        "ui_down",
        "ui_up"
    )

Output (broken)

func _input(event):
	var pitch_input = Input.get_axis("ui_up", "ui_down")
	if invert_pitch
	else Input.get_axis(
		"ui_down",
		"ui_up",
	)

Expected

Ternary should be preserved, possibly laid out like:

func _input(event):
	var pitch_input = Input.get_axis("ui_up", "ui_down") if invert_pitch else Input.get_axis(
		"ui_down",
		"ui_up",
	)

The formatter incorrectly treats if and else as statement keywords instead of ternary expression keywords.

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