Skip to content

Commit

Permalink
Fix missing spaces inside parentheses of function applications
Browse files Browse the repository at this point in the history
  • Loading branch information
dungpa committed Aug 10, 2015
1 parent 9aef8cf commit 3e99d64
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 1.9.0 - 19-08-2015
* Fix https://github.com/fsprojects/VisualFSharpPowerTools/issues/1050 ([#172](https://github.com/dungpa/fantomas/pull/172))

#### 1.8.0-beta - 19-07-2015
* Migrate to F# 4.0 ([#170](https://github.com/dungpa/fantomas/pull/170))

Expand Down
2 changes: 1 addition & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ NUGET
FsCheck (>= 1.0.0)
NUnit (>= 2.6.3)
NUnit.Runners (>= 2.6.3)
FSharp.Compiler.Service (1.4.0-beta) - framework: >= net45
FSharp.Compiler.Service (1.4.0.1) - framework: >= net45
FsUnit (1.3.0.1) - framework: >= net45
NUnit (>= 2.6.3)
NuGet.CommandLine (2.8.5)
Expand Down
10 changes: 10 additions & 0 deletions src/Fantomas.Tests/FunctionDefinitionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,14 @@ f(42).Length
let f x = "foo"
f(42).Length
"""

[<Test>]
let ``do add spaces for function application inside parentheses inside dot access``() =
formatSourceString false """let inputBlah = "So, I was like, Visual Studio did wat!?"
let someBlahing = (Blah.TryCreate inputBlah).Value""" config
|> prepend newline
|> should equal """
let inputBlah = "So, I was like, Visual Studio did wat!?"
let someBlahing = (Blah.TryCreate inputBlah).Value
"""
3 changes: 2 additions & 1 deletion src/Fantomas/CodeFormatter.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ let test (s : string) =
fsi.AddPrinter (fun (p : pos) -> p.ToString())
fsi.AddPrinter (fun (r : range) -> r.ToString())

let input = """[<Measure>] type X = cm^(1/2)/W"""
let input = """let inputBlah = "So, I was like, Visual Studio did wat!?"
let someBlahing = (Blah.TryCreate inputBlah).Value"""

test input;;

Expand Down
4 changes: 3 additions & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ and genExpr astContext = function
| MatchLambda(sp, _) -> !- "function " +> colPre sepNln sepNln sp (genClause astContext true)
| Match(e, cs) ->
atCurrentColumn (!- "match " +> genExpr astContext e -- " with" +> colPre sepNln sepNln cs (genClause astContext true))
| Paren e -> sepOpenT +> genExpr astContext e +> sepCloseT
| Paren e ->
// Parentheses nullify effects of no space inside DotGet
sepOpenT +> genExpr { astContext with IsInsideDotGet = false } e +> sepCloseT
| CompApp(s, e) ->
!- s +> sepSpace +> sepOpenS +> genExpr { astContext with IsNakedRange = true } e
+> ifElse (checkBreakForExpr e) (sepNln +> sepCloseSFixed) sepCloseS
Expand Down

0 comments on commit 3e99d64

Please sign in to comment.