Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Fantomas.Core.Tests/OperatorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,29 @@ let hasUnEvenAmount regex line =
- Regex.Matches(line, "\\\\" + regex).Count) % 2 = 1
"""

[<Test>]
let ``custom double-percent operator stays on same line as lhs when expression is too long, 2107`` () =
formatSourceString
"""
let inline (%%) x y = ((x % y) + y) % y
let aVeryLongVariableNameThatForceLineBreaking = 0
let a = (if aVeryLongVariableNameThatForceLineBreaking = 0 then 1 else -1) %% 4
"""
config
|> prepend newline
|> should
equal
"""
let inline (%%) x y = ((x % y) + y) % y
let aVeryLongVariableNameThatForceLineBreaking = 0

let a =
(if aVeryLongVariableNameThatForceLineBreaking = 0 then
1
else
-1) %% 4
"""

[<Test>]
let ``parameter after multiline string, 783`` () =
formatSourceString
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open Fantomas.Core.Context
open Fantomas.Core.SyntaxOak
open Microsoft.FSharp.Core.CompilerServices

let noBreakInfixOps = set [| "="; ">"; "<"; "%" |]
let noBreakInfixOps = set [| "="; ">"; "<"; "%"; "%%" |]
let newLineInfixOps = set [ "|>"; "||>"; "|||>"; ">>"; ">>=" ]

let rec (|UppercaseType|LowercaseType|) (t: Type) : Choice<unit, unit> =
Expand Down
Loading