Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep new line before SynExpr.DotIndexedSet. #1316

Merged
merged 1 commit into from
Dec 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/Fantomas.Tests/SynExprSetTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,58 @@ let ``multi line DotNamedIndexedPropertySet`` () =
|> string
|> StringValues
"""

[<Test>]
let ``keep new line before SynExpr.DotIndexedSet, 1314`` () =
formatSourceString
false
"""
match x with
| NotificationEvent.Lint (file, warnings) ->
let uri = Path.FilePathToUri file

diagnosticCollections.AddOrUpdate((uri, "F# Linter"), [||], (fun _ _ -> [||]))
|> ignore

let fs =
warnings
|> List.choose
(fun w ->
w.Warning.Details.SuggestedFix
|> Option.bind
(fun f ->
let f = f.Force()
let range = fcsRangeToLsp w.Warning.Details.Range

f
|> Option.map (fun f -> range, { Range = range; NewText = f.ToText })))

lintFixes.[uri] <- fs
"""
config
|> prepend newline
|> should
equal
"""
match x with
| NotificationEvent.Lint (file, warnings) ->
let uri = Path.FilePathToUri file

diagnosticCollections.AddOrUpdate((uri, "F# Linter"), [||], (fun _ _ -> [||]))
|> ignore

let fs =
warnings
|> List.choose
(fun w ->
w.Warning.Details.SuggestedFix
|> Option.bind
(fun f ->
let f = f.Force()
let range = fcsRangeToLsp w.Warning.Details.Range

f
|> Option.map (fun f -> range, { Range = range; NewText = f.ToText })))

lintFixes.[uri] <- fs
"""
1 change: 1 addition & 0 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2737,6 +2737,7 @@ and genExpr astContext synExpr ctx =
| SynExpr.Upcast _ -> genTriviaFor SynExpr_Upcast synExpr.Range
| SynExpr.Downcast _ -> genTriviaFor SynExpr_Downcast synExpr.Range
| SynExpr.DotIndexedGet _ -> genTriviaFor SynExpr_DotIndexedGet synExpr.Range
| SynExpr.DotIndexedSet _ -> genTriviaFor SynExpr_DotIndexedSet synExpr.Range
| _ -> id)

expr ctx
Expand Down