You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letfn()=iftruethen
DoSomething ()
DoSomethingElse()elif shouldWe then
Whatever()letnextfunc()=
printf "Hi"
Result
letfn()=iftruethen
DoSomething()
DoSomethingElse()elif shouldWe then
Whatever()letnextfunc()= printf "Hi"
Problem description
Nested ifs or if-else chains can result in additional blank lines being inserted with each reformat. This seems to happen only when they have an implicit unit-returning else tail.
I have many variants of this in my code. Some occur at the end of a function others in the middle of a function. In the latter case, the rest of the function is pushed further down the page with each iteration. In the former, the same happens to the following function.
Extra information
The formatted result breaks by code.
The formatted result gives compiler warnings.
I or my company would be willing to help fix this.
I am not familiar with the Fantomas code, but would be will to try to fix this with some pointers or hints.
In places I've had to resort to things like:
letprivatesetState(host:IViewHost)retryMsg program (state:Model)dispatch =// create new view and update the host only if new model is not equal to a prev oneletstateDiffers=(Some state).Equals(!stateRef)|>notif stateDiffers thenletupdated= state.ThrottleUpdates()|>not// Only build a new view if the screen has been updated with the previous oneif updated then
stateRef := Some state
letview=((Program.view program) state dispatch)
host.Update(Some(view :> IView))elif retryMsgInFlight |>notthen// Otherwise, dispatch a message after a while so that we can retry updating with the latest.
DispatcherTimer.RunOnce(Action(fun()-> retryMsg |> dispatch), TimeSpan.FromMilliseconds 50.0)|> ignore
retryMsgInFlight <-trueelse()// Avoid Fantomas formatting problemselse()// Avoid Fantomas formatting problems
Interestingly, if I only put the comment on one of the elses, Fantomas will insert it on both.
Hello @renngar, thanks for reporting this.
I believe we are adding a newline too much somewhere in CodePrinter.
Sorry that this doesn't really narrow this down a lot.
Issue created from fantomas-online
Code
Result
Problem description
Nested ifs or if-else chains can result in additional blank lines being inserted with each reformat. This seems to happen only when they have an implicit unit-returning
else
tail.I have many variants of this in my code. Some occur at the end of a function others in the middle of a function. In the latter case, the rest of the function is pushed further down the page with each iteration. In the former, the same happens to the following function.
Extra information
I am not familiar with the Fantomas code, but would be will to try to fix this with some pointers or hints.
In places I've had to resort to things like:
Interestingly, if I only put the comment on one of the elses, Fantomas will insert it on both.
Options
Fantomas Master at 10/02/2020 17:06:53 - 31305c2
Default Fantomas configuration
The text was updated successfully, but these errors were encountered: