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

Detect "matrix" wrapping? #433

Closed
Gama11 opened this issue Apr 7, 2019 · 1 comment
Closed

Detect "matrix" wrapping? #433

Gama11 opened this issue Apr 7, 2019 · 1 comment
Labels
enhancement New feature or request wrapping Incorrect or undesirable wrapping

Comments

@Gama11
Copy link
Member

Gama11 commented Apr 7, 2019

Often times, matrices / 2D arrays that are writen as 1D arrays are wrapped with the exact same number of elements in each line, for instance:

sampleMapArray = [
	0, 1, 0, 1,
	1, 1, 1, 1,
	1, 0, 0, 1
];
static var offsetAutoTile:Array<Int> = 
	[
		0, 0, 0, 0, 2, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
		11, 11, 0, 0, 13, 13, 0, 14, 0, 0, 0, 0, 18, 18, 0, 19,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		51, 51, 0, 0, 53, 53, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0,
		62, 62, 0, 0, 64, 64, 0, 65, 0, 0, 0, 0, 69, 69, 0, 70,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		86, 86, 0, 0, 88, 88, 0, 89, 0, 0, 0, 0, 93, 93, 0, 94,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 159, 0, 0, 0, 162, 0, 163, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 172, 0, 0, 0, 175, 0, 176, 0, 0, 0, 0, 0, 181, 0, 182,
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
		0, 199, 0, 0, 0, 202, 0, 203, 0, 0, 0, 0, 0, 208, 0, 209
	];
return [
	-1.0, -1.0, 0, 0,
	1.0, -1.0, 1, 0,
	-1.0,  1.0, 0, 1,
	1.0, -1.0, 1, 0,
	1.0,  1.0, 1, 1,
	-1.0,  1.0, 0, 1
];

I wonder if the formatter could be smart enough to detect this and leave it as-is? (and still do the usual thing if there's an inconsistent number of elements per line)

@Gama11 Gama11 added enhancement New feature or request wrapping Incorrect or undesirable wrapping labels Apr 7, 2019
@ibilon
Copy link

ibilon commented Apr 7, 2019

Something that'd be nice too, though probably even harder, would be to keep the alignment spaces in matrices like:

[-1.0, -1.0,  0,  0,
  1.0, -1.0, -1,  0,
 -1.0,  1.0,  0,  1,
  1.0, -1.0,  1,  0,
  1.0,  1.0, -1,  1,
 -1.0,  1.0,  0, -1];

AlexHaxe added a commit to AlexHaxe/haxe-formatter that referenced this issue Apr 10, 2019
AlexHaxe added a commit to AlexHaxe/haxe-formatter that referenced this issue Apr 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wrapping Incorrect or undesirable wrapping
Projects
None yet
Development

No branches or pull requests

2 participants