Skip to content

Fix newlines in multiline ternaries being removed#91

Merged
NathanLovato merged 1 commit intoGDQuest:mainfrom
TranquilMarmot:multiline-ternary
Sep 27, 2025
Merged

Fix newlines in multiline ternaries being removed#91
NathanLovato merged 1 commit intoGDQuest:mainfrom
TranquilMarmot:multiline-ternary

Conversation

@TranquilMarmot
Copy link
Copy Markdown
Contributor

Please check if the PR fulfills these requirements:

  • The commit message follows our guidelines.
  • For bug fixes and features:
    • You tested the changes.

Related issue (if applicable): #90

What kind of change does this PR introduce?

This fixes newlines inside of multiline ternary expressions being remove.

Does this PR introduce a breaking change?

No

New feature or change

What is the current behavior?

A good example of is when you have long ternary like so:

func _handle_look_input():
	var input_dir := (
		Input.get_vector(&"look_left", &"look_right", &"look_up", &"look_down")
		if _can_move()
		else Vector2.ZERO
	)

This will currently ignore the newline before the if and be turned into:

func _handle_look_input():
	var input_dir := (
		Input.get_vector(&"look_left", &"look_right", &"look_up", &"look_down") if _can_move()
		else Vector2.ZERO
	)

What is the new behavior?

Now, the newline inside of the parenthesis will be preserved.

func _handle_look_input():
	var input_dir := (
		Input.get_vector(&"look_left", &"look_right", &"look_up", &"look_down")
		if _can_move()
		else Vector2.ZERO
	)

Other information

@NathanLovato NathanLovato linked an issue Sep 27, 2025 that may be closed by this pull request
@NathanLovato NathanLovato merged commit 37d3e9b into GDQuest:main Sep 27, 2025
@NathanLovato
Copy link
Copy Markdown
Contributor

The help is much appreciated, thank you! Note that when something is documented in an issue, you don't have to worry about filling the template when opening a matching pull request. It's fine to just write e.g. "Close #90"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve handling of multiline ternary expressions

2 participants