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

Comment indentation in case #392

Closed
Gama11 opened this issue Mar 6, 2019 · 2 comments
Closed

Comment indentation in case #392

Gama11 opened this issue Mar 6, 2019 · 2 comments
Labels
enhancement New feature or request indentation Indentation is incorrect

Comments

@Gama11
Copy link
Member

Gama11 commented Mar 6, 2019

The formatter is smart enough to indent the comment here because no case follows it:

class Main {
	static function main() {
		switch ("c") {
			case "a":
			case "b":
			case _:
				// nothing to do
		}
	}
}

Maybe it should be indented here too, because case "a" is empty (so it's unlikely to be a comment belonging to the next case):

class Main {
	static function main() {
		switch ("c") {
			case "a":
			// nothing to do
			case "b":
			case _:
		}
	}
}
@Gama11 Gama11 added enhancement New feature or request indentation Indentation is incorrect labels Mar 6, 2019
@Gama11
Copy link
Member Author

Gama11 commented Mar 6, 2019

(consequently, in case of the case not being empty, it would look this)

class Main {
	static function main() {
		switch ("c") {
			case "a":
				trace("foo");
			// check for "b"
			case "b":
			case _:
		}
	}
}

@jeremyfa
Copy link

jeremyfa commented Feb 6, 2024

Just hitting similar problem (with default hxformat.json)

I wish there was a setting to just keep the current comment indentation in the case, as currently, the following code:

enum MyEnum {
	A;
	B;
	C;
	D;
}

class Main {
	public static function main() {
		var value:MyEnum = Math.random() < 0.5 ? A : B;

		switch value {
			case A:
				// Case A

			case B:
				// Case B
				trace('hello');

			case C:
				// Case C

			case D:
				// Case D
		}
	}
}

Brings me the following result:

enum MyEnum {
	A;
	B;
	C;
	D;
}

class Main {
	public static function main() {
		var value:MyEnum = Math.random() < 0.5 ? A : B;

		switch value {
			case A:
			// Case A

			case B:
				// Case B
				trace('hello');

			case C:
			// Case C

			case D:
				// Case D
		}
	}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request indentation Indentation is incorrect
Projects
None yet
Development

No branches or pull requests

2 participants