Skip to content

sameLine.returnBody - separate setting for single-line body #303

Closed
@gene-pavlovsky

Description

@gene-pavlovsky

Describe the Feature

The sameLine.returnBody option allows a complex return body to be moved to a new line.
However, it also forces real simple returns on the same line (e.g. return 10 becomes two lines), which is undesirable. It would be good if there was a way to have complex bodies such as if/else, switch etc. on a newline, and simple ones on the same line (the question is how exactly to distinguish simple from complex).

(Optional) Sample of desired output

class Main {
	function a() {
		return 10;
		return x < 0 ? "negative" : "non-negative";
	}
	function b() {
		return
			if (x < 0) "negative";
			else "non-negative";
		return
			switch y {
				case "negative": -1;
				case "non-negative": 1;
			}
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsamelinebroken same line formatting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions