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

expressionIf detection in array comprehension #365

Closed
Gama11 opened this issue Feb 17, 2019 · 1 comment
Closed

expressionIf detection in array comprehension #365

Gama11 opened this issue Feb 17, 2019 · 1 comment
Labels
bug Something isn't working sameline broken same line formatting

Comments

@Gama11
Copy link
Member

Gama11 commented Feb 17, 2019

Describe the bug

expressionIf detection seems to fail here (works if the if is prefixed with return directly):

Input file

class Main {
	static function main() {
		return [
			for (meta in node.metadata) {
				var child = node.children[meta - 1];
				if (child == null) 0 else value(child);
			}
		].sum();
	}
}

Broken output

class Main {
	static function main() {
		return [
			for (meta in node.metadata) {
				var child = node.children[meta - 1];
				if (child == null)
					0
				else
					value(child);
			}
		].sum();
	}
}
@Gama11 Gama11 added bug Something isn't working sameline broken same line formatting labels Feb 17, 2019
@Gama11
Copy link
Member Author

Gama11 commented Feb 17, 2019

Similar:

class Main {
	static function main() {
		[
			if (foo) bar else foo,
			if (foo) bar else foo,
			if (foo) bar else foo,
			if (foo) bar else foo,
			if (foo) bar else foo
		]
	}
}

becomes:

class Main {
	static function main() {
		[
			if (foo)
				bar
			else
				foo,
			if (foo)
				bar
			else
				foo,
			if (foo)
				bar
			else
				foo,
			if (foo)
				bar
			else
				foo,
			if (foo)
				bar
			else
				foo
		]
	}
}

AlexHaxe added a commit to AlexHaxe/haxe-formatter that referenced this issue Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sameline broken same line formatting
Projects
None yet
Development

No branches or pull requests

1 participant