Skip to content

Commit

Permalink
Move IndexWithoutDotExpr higher in the genExpr pattern match. (#1995)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Dec 29, 2021
1 parent 4655d77 commit 836314a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
15 changes: 15 additions & 0 deletions src/Fantomas.Tests/IndexSyntaxTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,18 @@ let y = [ 0; 2; 4 ][ 1 ]
"""
let y = [ 0; 2; 4 ][1]
"""

[<Test>]
let ``index syntax on dotget, 1985`` () =
formatSourceString
false
"""
let segment = System.Uri(ctx.Request.Path.Value).Segments[1]
"""
config
|> prepend newline
|> should
equal
"""
let segment = System.Uri(ctx.Request.Path.Value).Segments[1]
"""
12 changes: 6 additions & 6 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,12 @@ and genExpr astContext synExpr ctx =
+> genExpr astContext e3
)

| IndexWithoutDotExpr (identifierExpr, indexExpr) ->
genExpr astContext identifierExpr
+> sepOpenLFixed
+> genExpr astContext indexExpr
+> sepCloseLFixed

// Result<int, string>.Ok 42
| App (DotGet (TypeApp (e, lt, ts, gt), lids), es) ->
let s = List.map fst lids |> String.concat "."
Expand Down Expand Up @@ -2229,12 +2235,6 @@ and genExpr astContext synExpr ctx =

expressionFitsOnRestOfLine short long

| IndexWithoutDotExpr (identifierExpr, indexExpr) ->
genExpr astContext identifierExpr
+> sepOpenLFixed
+> genExpr astContext indexExpr
+> sepCloseLFixed

// Always spacing in multiple arguments
| App (e, es) -> genApp astContext e es
| TypeApp (e, lt, ts, gt) ->
Expand Down

0 comments on commit 836314a

Please sign in to comment.