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

Multiline function parameters

Open tavurth opened this issue 2 years ago • 3 comments
trafficstars

Currently they resolve to this:

	(
		to_return
		. assign(
			[
				[
					IronStomach,
					StrongStomach,
				],
				[
					PickyEater,
					AdventurousEater,
					CulinaryExpert,
				],
				[Gourmand, Foodie, FastMetabolism, CulinaryExpert],
			]
		)
	)

However having an option to output like this (ALA prettier.js) would be really nice:

	to_return.assign([
		[
			IronStomach,
			StrongStomach,
		],
		[
			PickyEater,
			AdventurousEater,
			CulinaryExpert,
		],
		[Gourmand, Foodie, FastMetabolism, CulinaryExpert],
	])

tavurth avatar May 10 '23 10:05 tavurth

yeah, I've been thinking about it - I need to take a serious look and check if this is doable

Scony avatar May 10 '23 20:05 Scony

Hi - I came to ask about this as well, but mostly because I seem to be seeing inconsistent formatting. Sometimes it seems to resolve to the first:


func _init(
	_gridWorldSize: float,
	_cellWorldSize: float,
	startPosition: Vector2,
	endPosition: Vector2,
	onCreepUpdate: Callable
):
	waypointManager = (
		WaypointManager
		. new(
			startPosition,
			endPosition,
		)
	)

while other times it seems to resolve to the second


func _ready():
	navigationManager = NavigationManager.new(
		gridWorldSize,
		cellWorldSize,
		Utils.toBoardVector(startNode.global_position),
		Utils.toBoardVector(endNode.global_position),
		updateCreepNode
	)

These examples are from the same project, but different files (the second option is preferred). Happy to provide more details if needed.

I'm running Godot 4.1.1, and the VSCode extension version v1.2.3

dxu avatar Nov 24 '23 20:11 dxu

@dxu in your case the difference comes from the fact that in some cases you're using trailing comma i.e. the following construct:

var x = [1,2,3,]

as opposed to

var x = [1,2,3]

In case of trailing comma, gdformat enforces multiline formatting.

Scony avatar Nov 26 '23 14:11 Scony

Actually the above was covered much better in my comment - https://github.com/Scony/godot-gdscript-toolkit/issues/295#issuecomment-2013728958 so closing this one as duplicate.

Scony avatar Mar 21 '24 21:03 Scony