diff --git a/.gitignore b/.gitignore
index 61ecbc39ba..0d3ffd147a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -110,7 +110,7 @@ stylecop.*
*.dbmdl
lib/*.xml
Generated_Code #added for RIA/Silverlight projects
-.ionide
+.ionide/
# Backup & report files from converting an old project file to a newer
# Visual Studio version. Backup files are not needed, because we have git ;-)
@@ -168,8 +168,6 @@ pip-log.txt
*.ncrunch*
TestResults.xml
*.xml
-.fake/build.fsx_*.dll
-.paket/paket.exe
paket-files/
.fake/
.vs/
@@ -181,10 +179,7 @@ paket-files/
# external projects directory for extensive regression tests
external-project-tests/
-.paket/.store/
-.paket/paket.exe
-.fake/
+.paket/
.vscode/
-.ionide
BenchmarkDotNet.Artifacts/
FormatChanged.ps1
\ No newline at end of file
diff --git a/.paket/Paket.Restore.targets b/.paket/Paket.Restore.targets
deleted file mode 100644
index c803f14910..0000000000
--- a/.paket/Paket.Restore.targets
+++ /dev/null
@@ -1,558 +0,0 @@
-
-
-
-
-
-
- $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
-
- $(MSBuildVersion)
- 15.0.0
- false
- true
-
- true
- $(MSBuildThisFileDirectory)
- $(MSBuildThisFileDirectory)..\
- $(PaketRootPath)paket-files\paket.restore.cached
- $(PaketRootPath)paket.lock
- classic
- proj
- assembly
- native
- /Library/Frameworks/Mono.framework/Commands/mono
- mono
-
-
- $(PaketRootPath)paket.bootstrapper.exe
- $(PaketToolsPath)paket.bootstrapper.exe
- $([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\
-
- "$(PaketBootStrapperExePath)"
- $(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"
-
-
-
-
- true
- true
-
-
- True
-
-
- False
-
- $(BaseIntermediateOutputPath.TrimEnd('\').TrimEnd('\/'))
-
-
-
-
-
-
-
-
- $(PaketRootPath)paket
- $(PaketToolsPath)paket
-
-
-
-
-
- $(PaketRootPath)paket.exe
- $(PaketToolsPath)paket.exe
-
-
-
-
-
- <_DotnetToolsJson Condition="Exists('$(PaketRootPath)/.config/dotnet-tools.json')">$([System.IO.File]::ReadAllText("$(PaketRootPath)/.config/dotnet-tools.json"))
- <_ConfigContainsPaket Condition=" '$(_DotnetToolsJson)' != ''">$(_DotnetToolsJson.Contains('"paket"'))
- <_ConfigContainsPaket Condition=" '$(_ConfigContainsPaket)' == ''">false
-
-
-
-
-
-
-
-
-
-
- <_PaketCommand>dotnet paket
-
-
-
-
-
- $(PaketToolsPath)paket
- $(PaketBootStrapperExeDir)paket
-
-
- paket
-
-
-
-
- <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))
- <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"
- <_PaketCommand Condition=" '$(_PaketCommand)' == '' AND '$(OS)' != 'Windows_NT' AND '$(_PaketExeExtension)' == '.exe' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"
- <_PaketCommand Condition=" '$(_PaketCommand)' == '' ">"$(PaketExePath)"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
- $(NoWarn);NU1603;NU1604;NU1605;NU1608
- false
- true
-
-
-
-
-
-
-
-
- $([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))
-
-
-
-
-
-
- $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[0].Replace(`"`, ``).Replace(` `, ``))
- $([System.Text.RegularExpressions.Regex]::Split(`%(Identity)`, `": "`)[1].Replace(`"`, ``).Replace(` `, ``))
-
-
-
-
- %(PaketRestoreCachedKeyValue.Value)
- %(PaketRestoreCachedKeyValue.Value)
-
-
-
-
- true
- false
- true
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $(PaketIntermediateOutputPath)\$(MSBuildProjectFile).paket.references.cached
-
- $(MSBuildProjectFullPath).paket.references
-
- $(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references
-
- $(MSBuildProjectDirectory)\paket.references
-
- false
- true
- true
- references-file-or-cache-not-found
-
-
-
-
- $([System.IO.File]::ReadAllText('$(PaketReferencesCachedFilePath)'))
- $([System.IO.File]::ReadAllText('$(PaketOriginalReferencesFilePath)'))
- references-file
- false
-
-
-
-
- false
-
-
-
-
- true
- target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths)
-
-
-
-
-
-
-
-
-
-
- false
- true
-
-
-
-
-
-
-
-
-
-
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length)
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[6])
- $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[7])
-
-
- %(PaketReferencesFileLinesInfo.PackageVersion)
- All
- runtime
- runtime
- $(ExcludeAssets);contentFiles
- $(ExcludeAssets);build;buildMultitargeting;buildTransitive
- true
- true
-
-
-
-
- $(PaketIntermediateOutputPath)/$(MSBuildProjectFile).paket.clitools
-
-
-
-
-
-
-
-
- $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[0])
- $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[1])
-
-
- %(PaketCliToolFileLinesInfo.PackageVersion)
-
-
-
-
-
-
-
-
-
- false
-
-
-
-
-
- <_NuspecFilesNewLocation Include="$(PaketIntermediateOutputPath)\$(Configuration)\*.nuspec"/>
-
-
-
-
-
- $(MSBuildProjectDirectory)/$(MSBuildProjectFile)
- true
- false
- true
- false
- true
- false
- true
- false
- true
- false
- true
- $(PaketIntermediateOutputPath)\$(Configuration)
- $(PaketIntermediateOutputPath)
-
-
-
- <_NuspecFiles Include="$(AdjustedNuspecOutputPath)\*.$(PackageVersion.Split(`+`)[0]).nuspec"/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Fantomas.Tests/AppTests.fs b/src/Fantomas.Tests/AppTests.fs
index faada460f8..69172f97bf 100644
--- a/src/Fantomas.Tests/AppTests.fs
+++ b/src/Fantomas.Tests/AppTests.fs
@@ -708,3 +708,43 @@ let tryDataOperation =
[ parameters ]
(objectStateExpr body)
"""
+
+[]
+let ``comment after lambda inside parenthesis argument, 1822`` () =
+ formatSourceString
+ false
+ """
+module Foo =
+
+ let blah =
+ it
+ |> List.iter (fun (_, output) ->
+ thing
+ |> Map.iter (fun key value ->
+ match value with
+ | Ok (TestResult.Failure f) -> failwith ""
+ | Error e -> failwith ""
+ | _ -> () // hi!
+ )
+ )
+"""
+ config
+ |> prepend newline
+ |> should
+ equal
+ """
+module Foo =
+
+ let blah =
+ it
+ |> List.iter
+ (fun (_, output) ->
+ thing
+ |> Map.iter
+ (fun key value ->
+ match value with
+ | Ok (TestResult.Failure f) -> failwith ""
+ | Error e -> failwith ""
+ | _ -> () // hi!
+ ))
+"""
diff --git a/src/Fantomas.Tests/MultiLineLambdaClosingNewlineTests.fs b/src/Fantomas.Tests/MultiLineLambdaClosingNewlineTests.fs
index 72cb41db5a..cf09c2a755 100644
--- a/src/Fantomas.Tests/MultiLineLambdaClosingNewlineTests.fs
+++ b/src/Fantomas.Tests/MultiLineLambdaClosingNewlineTests.fs
@@ -839,3 +839,42 @@ module Foo =
| _ -> ""
)
"""
+
+[]
+let ``comment after single lambda in parenthesis argument`` () =
+ formatSourceString
+ false
+ """
+module Foo =
+
+ let blah =
+ it
+ |> List.iter (fun (_, output) ->
+ thing
+ |> Map.iter (fun key value ->
+ match value with
+ | Ok (TestResult.Failure f) -> failwith ""
+ | Error e -> failwith ""
+ | _ -> () // hi!
+ )
+ )
+"""
+ config
+ |> prepend newline
+ |> should
+ equal
+ """
+module Foo =
+
+ let blah =
+ it
+ |> List.iter (fun (_, output) ->
+ thing
+ |> Map.iter (fun key value ->
+ match value with
+ | Ok (TestResult.Failure f) -> failwith ""
+ | Error e -> failwith ""
+ | _ -> () // hi!
+ )
+ )
+"""
diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs
index a7e1900166..a84c7e88fc 100644
--- a/src/Fantomas/CodePrinter.fs
+++ b/src/Fantomas/CodePrinter.fs
@@ -1486,8 +1486,16 @@ and genExpr astContext synExpr ctx =
+> triviaAfterArrow arrowRange
+> ifElse
hasLineCommentAfterArrow
- (body +> sepCloseTFor rpr pr)
- (autoNlnIfExpressionExceedsPageWidth (body +> sepCloseTFor rpr pr))
+ (body
+ +> triviaOfLambda printContentAfter
+ +> sepNlnWhenWriteBeforeNewlineNotEmpty id
+ +> sepCloseTFor rpr pr)
+ (autoNlnIfExpressionExceedsPageWidth (
+ body
+ +> triviaOfLambda printContentAfter
+ +> sepNlnWhenWriteBeforeNewlineNotEmpty id
+ +> sepCloseTFor rpr pr
+ ))
+> unindent
expr ctx
@@ -3050,23 +3058,25 @@ and genApp astContext e es ctx =
sepSpace
es
(fun e ->
- let genLambda pats (bodyExpr: SynExpr) lpr rpr arrowRange =
- sepOpenTFor lpr -- "fun "
- +> pats
- +> indent
- +> triviaAfterArrow arrowRange
- +> autoNlnIfExpressionExceedsPageWidth (genExprKeepIndentInBranch astContext bodyExpr)
+ let genLambda pats (bodyExpr: SynExpr) lpr rpr arrowRange lambdaRange =
+ sepOpenTFor lpr
+ +> (!- "fun "
+ +> pats
+ +> indent
+ +> triviaAfterArrow arrowRange
+ +> autoNlnIfExpressionExceedsPageWidth (genExprKeepIndentInBranch astContext bodyExpr)
+ |> genTriviaFor SynExpr_Lambda lambdaRange)
+> unindent
+> sepNln
+> sepCloseTFor rpr e.Range
match e with
- | Paren (lpr, Lambda (pats, expr, _range), rpr, _) ->
+ | Paren (lpr, Lambda (pats, expr, range), rpr, _) ->
let arrowRange =
List.last pats
|> fun lastPat -> ctx.MkRange lastPat.Range.End expr.Range.Start
- genLambda (col sepSpace pats (genPat astContext)) expr lpr rpr arrowRange
+ genLambda (col sepSpace pats (genPat astContext)) expr lpr rpr arrowRange range
| Paren (lpr, (MatchLambda _ as me), rpr, pr) ->
sepOpenTFor lpr
+> indent