haxe-formatter icon indicating copy to clipboard operation
haxe-formatter copied to clipboard

Long expression-if

Open Gama11 opened this issue 7 years ago • 1 comments

Describe the bug
At some point it should probably switch to "regular mode" instead of trying to keep it in one line?

Input file

class Main {
	static function main() {
		var msg = if( tinf.module != inf.module ) "module "+inf.module+" should be "+tinf.module;
			else if( tinf.doc != inf.doc ) "documentation is different";
			else if( tinf.isPrivate != inf.isPrivate ) "private flag is different";
			else if( !sameType ) "type kind is different";
			else "could not merge definition";
	}
}

Broken output

class Main {
	static function main() {
		var msg = if (tinf.module != inf.module) "module " + inf.module + " should be " + tinf.module; else if (tinf.doc != inf.doc)
			"documentation is different"; else if (tinf.isPrivate != inf.isPrivate) "private flag is different"; else if (!sameType) "type kind is different"; else
			"could not merge definition";
	}
}

Gama11 avatar Feb 16 '19 10:02 Gama11

I plan on adding a proper wrapping option for if-else chains used in expression-ifs, so they don't run into default wrapping.

AlexHaxe avatar Feb 16 '19 11:02 AlexHaxe