Skip to content

Long chains with some long arguments followed by method calls or property accesses could be more harmonious #360

Description

@NathanLovato

From a course module we're working on. Input:

	tween.tween_method(
		func(t: float) -> void:
			if move_and_collide(start.lerp(destination, t) - global_position):
				tween.kill()
				_transition_to_state(State.NORMAL),
		0.0, 1.0, duration
	).set_trans(Hook.PULL_TRANS).set_ease(Hook.PULL_EASE)

Current output:

	tween \
			.tween_method(
		func(t: float) -> void:
			if move_and_collide(start.lerp(destination, t) - global_position):
				tween.kill()
				_transition_to_state(State.NORMAL),
		0.0,
		1.0,
		duration,
	) \
			.set_trans(Hook.PULL_TRANS) \
			.set_ease(Hook.PULL_EASE)

In this case, it's probably more readable as a result to keep the tail end of the chain after the long arguments on a single line if possible. And for the first line, we definitely want not to wrap.

The parser is seeing this as a chain too long to fit on a single line, and it tries to consistently add backslashes for vertical chains of method calls and align the property accesses/method calls vertically.

Desired output:

	tween.tween_method(
		func(t: float) -> void:
			if move_and_collide(start.lerp(destination, t) - global_position):
				tween.kill()
				_transition_to_state(State.NORMAL),
		0.0,
		1.0,
		duration,
	).set_trans(Hook.PULL_TRANS).set_ease(Hook.PULL_EASE)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions