Open ghivert opened 3 years ago
Is it on purpose or because of some rules on closures?
It's a consequence of the general rule that the body of a function declaration using =>
is indented relative to the declaration itself. Curried style is really uncommon in Dart, so the formatter doesn't have any special rules to handle it better.
Do you think we could add this special case to the formatter ?
I think it's unlikely. Nested functions are a difficult corner of the formatter's rules and it's hard to change how they are handled without producing worse output in other cases. If this was a common style, it would be worth the effort, but I almost never see Dart code like this. I'll leave the issue open and if I get time I can investigate it, but it likely won't be a high priority.
I think this issue is a special case of my general issue https://github.com/dart-lang/dart_style/issues/1083
Hi !
I really like the formatter, but there’s some cases where I wonder if it’s by design or not. I wonder mainly about curried functions. I’m coming mainly from functional programming (Haskell and stuff) and it’s usual to have something like this:
But when doing the latter, it’s indented like this:
It feels like there’s two unneeded spaces in the function body. With indent guides and other stuff, it renders strangely. Is it on purpose or because of some rules on closures? I know we can do it differently, like:
It’s a similar result in the end, but it’s a slightly different code. What do you think about this?