-
-
Notifications
You must be signed in to change notification settings - Fork 193
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
Preserve more newlines #449
Comments
I'm very much in favor of having such an option and most probably we'd enable it by default in Rider to work similarly to other languages in the platform. An exception where I'd expect these newlines not to be preserved is when the line doesn't fit to desired width. |
Another example I can come up with is pattern matching: match meh with
| Foo ->
printfn "foo"
| Bar ->
printfn "bar" We could detect that nothing (or all spaces) follow after the |
When I'm writing something, I always do line-breaking regardless, be it after = or ->. That's because I'm still figuring out what I exactly want to do and I want to keep typing forward without causing syntactical problems. On the contrary: imagine another mindset of, as I'm typing something, I need to constantly keep thinking about whether I should've added a newline or not way back there; that's just interrupting my train of thought to care about formatting, something Fantomas should care about for me. I'm also afraid that such option would make the code look inconsistent after refactoring. A case where you refactor a large function with a lot of code:
But later you break this big function into two separate functions and its body becomes small
Now you have a "lingering" newline there that's probably unintended, as trivia would normally format everything in a single line. I guess it also opens up the question of whether composition/piping operators should always split everything vertically, because I'm noticing it only splits up the body if there are three of more functions being chained in a row. |
Now, about One of the branches is small, so only THAT ONE branch is kept inline If one of the branches need to go to the next line, then every single branch should follow suit and go under also, but maybe that's a different setting or something. |
I would also like to preserve newlines before let watchFiles =
async {
printfn "after start"
use _ =
!!(serverPath </> "*.fs") ++ (serverPath </> "*.fsproj") // combines fs and fsproj
|> ChangeWatcher.run (fun changes ->
printfn
"FILE CHANGE %A"
changes
// stopFunc()
//Async.Start (startFunc())
)
()
} When this is formatted it will look something like: let watchFiles =
async {
printfn "after start"
use _ =
!!(serverPath </> "*.fs") ++ (serverPath </> "*.fsproj") |> ChangeWatcher.run (fun changes -> // combines fs and fsproj
printfn
"FILE CHANGE %A"
changes
// stopFunc()
//Async.Start (startFunc())
)
()
} If #559 was not a problem I would have a workaround for this so it is not a big must to have this. |
The |
@nojaf I think I'm running into a situation where this feature would come in handy: example in online tool Perhaps I'm just missing some obvious setting, but it's the first thing I ran into when trying to use Elmish.WPF in Rider.
|
Hello, this feature was removed for good reason. |
Yeah, I mean this is just the basic Elmish sample app, but I suppose it happens anytime you have a longish pipeline expression and a list with a pipeline expression in the same file. Per-file style configuration doesn't seem really viable to me in the long term for larger (team) projects, but I'll look into it, thanks. I guess it's just an odd experience that newlines aren't preserved coming from e.g. R#. |
In light of recent improvements by the Trivia PR (#434) we would like to discuss the addition of a new setting.
With this setting, we could preserve newlines that were found in the source after certain tokens.
Example:
This sample would now be formatted on one line as it is very short.
If personal preference allows it, we could keep the newline after the
=
sign.A similar thing could be done with chained function calls.
Fantomas would format this one line because it is short.
With this new setting, we could detect that if a line begins with
.
, we keep the newline.By default, we would set this setting to false.
Thoughts and opinions?
//cc @jindraivanek @auduchinok
The text was updated successfully, but these errors were encountered: