Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* fix 1937

* fix format

* Use formatSourceString in unit test.

Co-authored-by: nojaf <florian.verdonck@outlook.com>
  • Loading branch information
2 people authored and jindraivanek committed Mar 30, 2022
1 parent 877a536 commit 331a08c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/Fantomas.Tests/OperatorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1256,3 +1256,32 @@ let subtractTwo = + {literalValue}
$"""
let subtractTwo = + {literalValue}
"""
[<Test>]
let ``qualified name to active pattern, 1937`` () =
formatSourceString
false
"""
StringPosition.(|TrimStart|)
(|TrimStart|)
StringPosition.(|TrimStart|_|)
(|TrimStart|_|)
StringPosition.(|A|B|)
(|A|B|)

let f (|A|B|) = (|A|B|)
"""
config
|> prepend newline
|> should
equal
"""
StringPosition.(|TrimStart|)
(|TrimStart|)
StringPosition.(|TrimStart|_|)
(|TrimStart|_|)
StringPosition.(|A|B|)
(|A|B|)

let f (|A|B|) = (|A|B|)
"""
6 changes: 5 additions & 1 deletion src/Fantomas/SourceParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ let (|Ident|) (s: Ident) =
| "not" -> "not"
| "params" -> "``params``"
| "parallel" -> "``parallel``"
| _ -> PrettyNaming.AddBackticksToIdentifierIfNeeded ident
| _ ->
if IsActivePatternName ident then
sprintf "(%s)" (DecompileOpName ident)
else
PrettyNaming.AddBackticksToIdentifierIfNeeded ident

let (|LongIdent|) (li: LongIdent) =
li
Expand Down

0 comments on commit 331a08c

Please sign in to comment.