Skip to content

Commit

Permalink
apply spacing between operators and all SynExpr.Const (#1980)
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel committed Nov 24, 2021
1 parent 720227d commit c6314fc
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ Target.create
if result.ExitCode = 0 then
Trace.log "No files need formatting"
elif result.ExitCode = 99 then
failwith "Some files need formatting, check output for more info"
failwith "Some files need formatting, run `dotnet fake build -t Format` to format them"
else
Trace.logf "Errors while formatting: %A" result.Errors)

Expand Down
37 changes: 37 additions & 0 deletions src/Fantomas.Tests/OperatorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1226,3 +1226,40 @@ module Foo =
| true -> id
| false -> id)
"""
let operator_application_literal_values =
[ "-86y"
"86uy"
"-86s"
"86us"
"-86"
"-86l"
"86u"
"86ul"
"-123n"
"0x00002D3Fun"
"-86L"
"86UL"
"-4.41F"
"-4.14"
"-12456I"
"-0.7833M"
"'a'"
"\"text\""
"'a'B"
"\"text\"B" ]
[<TestCaseSource("operator_application_literal_values")>]
let ``operators maintain spacing from literal values`` (literalValue: string) =
formatSourceString
false
$"""
let subtractTwo = + {literalValue}
"""
config
|> prepend newline
|> should
equal
$"""
let subtractTwo = + {literalValue}
"""
2 changes: 1 addition & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ and genExpr astContext synExpr ctx =
| PrefixApp (s, e) ->
let extraSpaceBeforeString =
match e with
| String _
| SynExpr.Const _
| SynExpr.InterpolatedString _ -> sepSpace
| _ -> sepNone

Expand Down

0 comments on commit c6314fc

Please sign in to comment.