Skip to content

Commit

Permalink
Put SynExpr.DotGet atCurrentColumn in if expression. Fixes fsprojects…
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Dec 23, 2020
1 parent 6695a60 commit e2edb56
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/Fantomas.Tests/IfThenElseTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1690,3 +1690,51 @@ module X =
()
"""

[<Test>]
let ``if expression with SynExpr.DotGet inside, 1329`` () =
formatSourceString
false
"""
let private tryGetUrlWithExactMatch (pathPattern: string<SourcelinkPattern>) (urlPattern: string<Url>) (document: Document) =
if (UMX.untag pathPattern).Equals(UMX.untag document.Name, System.StringComparison.Ordinal)
then Some (urlPattern, normalizeRepoPath (UMX.cast<SourcelinkPattern, RepoPathSegment> pathPattern), document) else None
let private tryGetUrlWithExactMatch
(pathPattern: string<SourcelinkPattern>)
(urlPattern: string<Url>)
(document: Document)
=
if (UMX.untag pathPattern)
.Equals(UMX.untag document.Name, System.StringComparison.Ordinal) then
Some(urlPattern, normalizeRepoPath (UMX.cast<SourcelinkPattern, RepoPathSegment> pathPattern), document)
else
None
"""
{ config with IndentSize = 2 }
|> prepend newline
|> should
equal
"""
let private tryGetUrlWithExactMatch
(pathPattern: string<SourcelinkPattern>)
(urlPattern: string<Url>)
(document: Document)
=
if (UMX.untag pathPattern)
.Equals(UMX.untag document.Name, System.StringComparison.Ordinal) then
Some(urlPattern, normalizeRepoPath (UMX.cast<SourcelinkPattern, RepoPathSegment> pathPattern), document)
else
None
let private tryGetUrlWithExactMatch
(pathPattern: string<SourcelinkPattern>)
(urlPattern: string<Url>)
(document: Document)
=
if (UMX.untag pathPattern)
.Equals(UMX.untag document.Name, System.StringComparison.Ordinal) then
Some(urlPattern, normalizeRepoPath (UMX.cast<SourcelinkPattern, RepoPathSegment> pathPattern), document)
else
None
"""
1 change: 1 addition & 0 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2419,6 +2419,7 @@ and genExpr astContext synExpr ctx =
+> (match e1 with
| SynExpr.TryWith _
| SynExpr.TryFinally _ -> sepOpenT +> genExpr astContext e1 +> sepCloseT
| App (SynExpr.DotGet _, [ (Paren _) ]) -> atCurrentColumn (genExpr astContext e1)
| AppTuple _ when (isConditionMultiline) ->
sepOpenT
+> atCurrentColumn (genExpr astContext e1)
Expand Down
1 change: 1 addition & 0 deletions src/Fantomas/SourceParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ let (|App|_|) e =
// captures application with single tuple arg
let (|AppTuple|_|) =
function
| App (SynExpr.DotGet _, [ (Paren (_, Tuple _, _)) ]) -> None
| App (e, [ (Paren (lpr, Tuple args, rpr)) ]) -> Some(e, lpr, args, rpr)
| App (e, [ (Paren (lpr, singleExpr, rpr)) ]) ->
match singleExpr with
Expand Down

0 comments on commit e2edb56

Please sign in to comment.