Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdformat collapses multiline-function call in chained function, exceeding line length #139

Closed
rcorre opened this issue Sep 18, 2021 · 5 comments
Labels
enhancement New feature or request formatter
Milestone

Comments

@rcorre
Copy link
Contributor

rcorre commented Sep 18, 2021

This file is formatted correctly:

extends Node


func _physics_process(delta: float):
	var move_target := Vector2(
		Input.get_action_strength("right") - Input.get_action_strength("left"),
		Input.get_action_strength("forward") - Input.get_action_strength("backward")
	)

Now add a method call on the end:

extends Node


func _physics_process(delta: float):
	var move_target := Vector2(
		Input.get_action_strength("right") - Input.get_action_strength("left"),
		Input.get_action_strength("forward") - Input.get_action_strength("backward")
	).rotated(20)

gdformat collapses it into one line, breaking the line length restriction:

extends Node


func _physics_process(delta: float):
	var move_target := Vector2(Input.get_action_strength("right") - Input.get_action_strength("left"), Input.get_action_strength("forward") - Input.get_action_strength("backward")).rotated(
		20
	)
@Scony
Copy link
Owner

Scony commented Sep 19, 2021

Actually that's expected - due to several Godot bugs (like e.g. https://github.com/Scony/godot-gdscript-toolkit/blob/master/tests/potential-godot-bugs/multiline-attribute-expression.gd) it's not possible to implement it the way I want.

Thus it will be addressed for 4.0 or 4.x.

@Scony Scony added enhancement New feature or request formatter labels Sep 19, 2021
@Scony Scony added this to the 4.0 milestone Sep 19, 2021
@Scony
Copy link
Owner

Scony commented Sep 19, 2021

As a workaround, I can only recommend introducing an extra variable or modifying move_target inplace.

@rcorre
Copy link
Contributor Author

rcorre commented Sep 20, 2021

Thanks! Do you happen to know which Godot issues, so I can track them?

@Scony
Copy link
Owner

Scony commented Sep 20, 2021

@rcorre the issues are solved in Godot's master branch already.

@Scony
Copy link
Owner

Scony commented Oct 21, 2022

fixed on master by f99c69d

@Scony Scony closed this as completed Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request formatter
Projects
None yet
Development

No branches or pull requests

2 participants