-
-
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
Consider Trivia Content before multiline members - fixes #569 #584
Consider Trivia Content before multiline members - fixes #569 #584
Conversation
The pattern matching above uses nested `sepMember` function to consider Trivia Content. The difference between those pattern matching cases is that latter one matches on when there are trailing non-multiline members. There's some code duplication between those two now, which I'm happy to refactor - feedback welcome.
This makes all tests still happy, but I'm not sure if I didn't do something stupid here. Good thing is it clears up the code a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add a unit test for the original reproduction
Plus addressing review comments
Addressed the comments I've also found 3 more cases where extra unwanted newline is being added - gonna tackle them as they're the outstanding issues preventing me from starting using fantomas in my project. [<Test>]
let ``no extra new line before nested module with attribute, 569``() =
let original = """module A =
let x = 0
[<RequireQualifiedAccess>]
module B =
let y = 1
"""
formatSourceString false original config |> should equal original
[<Test>]
let ``no extra new line after elif expression, 569``() =
let original = """let x =
if true then printfn "a"
elif true then printfn "b"
if true then 1 else 0
"""
formatSourceString false original config |> should equal original
[<Test>]
let ``no extra new line before abstract member with attribute, 569``() =
let original = """type A =
[<EmitConstructor>]
abstract Create: Unit -> A
abstract b: Unit -> Unit
"""
formatSourceString false original config |> should equal original Do you want me to combine those 3 more cases with this PR and issue, or shall I create a separate one? |
Hey @theimowski , thanks for the changes. |
Ok, created #586 |
The pattern matching above uses nested
sepMember
functionto consider Trivia Content. The difference between those
pattern matching cases is that latter one matches on when
there are trailing non-multiline members.
There's some code duplication between those two now, which
I'm happy to refactor - feedback welcome.