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

When a ternary is too long to fit in a single line, attempt to fit only the condition in that line #1342

Closed
rrousselGit opened this issue Dec 15, 2023 · 4 comments

Comments

@rrousselGit
Copy link

Consider a case were a ternary is too long to fit within the 80/120 line length.
Currently, it would try to format as:

var value = 
   conditon ? a : b;

Would it be reasonable to format it over multiple lines instead?

var value = condition
  ? a
  : b;
@srawlins
Copy link
Member

The conditional expression is not too long to fit into one line, in that example. It fits nicely in the second line.

@rrousselGit
Copy link
Author

rrousselGit commented Dec 15, 2023

It is too long to fit in the line it is associated with.

@rrousselGit
Copy link
Author

That random line-break to fit the code in the next line is something I avoid everywhere it can happen.

For example instead of:

var value = 
  foo(param);

I write:

final value = foo(
  value,
);

But we have no equivalent for ternaries

@munificent
Copy link
Member

I'm going to close this in favor of #1465 which is newer, but has more context about why the new formatter doesn't support it yet.

@munificent munificent closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants