Skip to content

Regression: Multiline lambdas incorrectly formatted #219

@bennbollay

Description

@bennbollay

First of all, let me state for the record: I appreciate the work you've done here and the difficulty of this problem.

Between 0.14.0 and 0.18.2 formatting within embedded lambdas changed, preventing the lambda from being recognized as continuing over multiple lines. This reproduction is extremely fragile, depending on two lines of whitespace at the top of the file, and the line between the two print statements, to either work or not work accordingly.

Input file:



func f9():
	connect(
		func():
			print("THIS LINE IS CORRECT")

			print("THIS LINE IS INCORRECT")
	)

Note: the two blank lines at the top, these are necessary.
Note: the empty line between the two print statements can have tab indentation, but does not need to have tab indentation

Result using 0.14.0:

% gdscript-formatter-0.14.0-macos-aarch64 --stdout ./test.gd
func f9():
	connect(
		func():
			print("THIS LINE IS CORRECT")

			print("THIS LINE IS INCORRECT")
	)

Result using 0.18.2:

% gdscript-formatter-0.18.2-macos-aarch64 --stdout ./test.gd
func f9():
	connect(
		func():
			print("THIS LINE IS CORRECT")

	print("THIS LINE IS INCORRECT")
	)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions