godot-gdscript-toolkit icon indicating copy to clipboard operation
godot-gdscript-toolkit copied to clipboard

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

Open rcorre opened this issue 4 years ago • 4 comments

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
	)

rcorre avatar Sep 18 '21 14:09 rcorre

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 avatar Sep 19 '21 20:09 Scony

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

Scony avatar Sep 19 '21 20:09 Scony

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

rcorre avatar Sep 20 '21 11:09 rcorre

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

Scony avatar Sep 20 '21 11:09 Scony

fixed on master by f99c69d7b64dac281cac42dd952eb4e54c58e80a

Scony avatar Oct 21 '22 21:10 Scony