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

leftCurly: both with anonymous types #301

Closed
gene-pavlovsky opened this issue Jan 29, 2019 · 5 comments · Fixed by #309
Closed

leftCurly: both with anonymous types #301

gene-pavlovsky opened this issue Jan 29, 2019 · 5 comments · Fixed by #309
Labels
bug Something isn't working

Comments

@gene-pavlovsky
Copy link

Describe the bug

With lineEnds.leftCurly option set to both, the anonymous object type declarations have an unwanted newline added before (but not after) the {.

Input file

typedef Point2D = {x:Int, y:Int};
typedef Point3D = {x:Int, y:Int, z:Int};

class A {
	var a:{x:Int, y:Int, z:Int};
}

Broken output

typedef Point2D =
{x:Int, y:Int};

typedef Point3D =
{x:Int, y:Int, z:Int};

class A
{
	var a:
		{x:Int, y:Int, z:Int};
}
@AlexHaxe AlexHaxe added the bug Something isn't working label Jan 29, 2019
AlexHaxe added a commit to AlexHaxe/haxe-formatter that referenced this issue Feb 3, 2019
…xeCheckstyle#299

fixed anon types and leftCurly=both, fixes HaxeCheckstyle#301
fixed same line handling of expressionIf, fixes HaxeCheckstyle#304
fixed indentation of object literals, fixes HaxeCheckstyle#305
fixed same line handling of cases with object patterns, fixes HaxeCheckstyle#306
fixed empty line after class metadata with function, fixes HaxeCheckstyle#307
fixed missing space between Comman and POpen, fixes HaxeCheckstyle#308
refactored to increase null safety
AlexHaxe added a commit that referenced this issue Feb 3, 2019
#309)

* added wrapping location to allow wrapping before delimiter, fixes #299
* fixed anon types and leftCurly=both, fixes #301
* fixed same line handling of expressionIf, fixes #304
* fixed indentation of object literals, fixes #305
* fixed same line handling of cases with object patterns, fixes #306
* fixed empty line after class metadata with function, fixes #307
* fixed missing space between Comman and POpen, fixes #308
* refactored to increase null safety
@gene-pavlovsky
Copy link
Author

With formatter 1.5.1, the output looks like this now:

typedef Point2D =
{
	x:Int,
	y:Int
};

typedef Point3D =
{
	x:Int,
	y:Int,
	z:Int
};

class A
{
	var a:
		{x:Int, y:Int, z:Int};
}

@AlexHaxe
Copy link
Member

I've created a testcase for #301 (https://github.com/HaxeCheckstyle/haxe-formatter/blob/master/test/testcases/lineends/issue_301_typedef_anon_type.hxtest), so technically it should work - since TravisCI is green.
I guess your configuration has additional options that come into play here.

Can you narrow your configuration down to help figure out why it fails for you?

@gene-pavlovsky
Copy link
Author

{
	"lineEnds": {
		"leftCurly": "both"
	},
	"wrapping": {
		"anonType": {"defaultWrap": "keep"}
	}
}

results in

	var a:
		{x:Int, y:Int, z:Int};

P.S. At my workplace we have a weird style where left curly is usually on a new line, but in case of literal objects or anonymous types it's on the same line. There's no setting to achieve that, right?

@AlexHaxe
Copy link
Member

thanks, that indeed misbehaves...

no, there is currently no setting allowing different curly options for object literals or anon types, see #346
I think @cmandlbaur was working on some parts of it, but I'm not sure how far he got

@AlexHaxe AlexHaxe reopened this Mar 21, 2019
@gene-pavlovsky
Copy link
Author

Thanks for the link, I left a comment there as it didn't include my anonymous type case

AlexHaxe added a commit to AlexHaxe/haxe-formatter that referenced this issue Mar 21, 2019


added CLI option --stdin to switch to stdin/stdout mode, fixes HaxeCheckstyle#411
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants