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

Fix 360 #361

Merged
merged 5 commits into from
Nov 21, 2018
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
5 changes: 3 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 2.9.2 - XX-2018
* Fix preserveEndOfLine introduces additional newlines. [#360](https://github.com/fsprojects/fantomas/issues/360)

#### 2.9.1 - 11-2018
* Added instructions for vscode and online website. [#333](https://github.com/fsprojects/fantomas/pull/333)
* Removed trailing spaces for each line, after formatting. [#328](https://github.com/fsprojects/fantomas/issues/328)
Expand All @@ -11,8 +14,6 @@
* Added regression test for Implicit module is added to resulting code. [#355](https://github.com/fsprojects/fantomas/pull/355)
* Fix wrong comment placement. [#289](https://github.com/fsprojects/fantomas/issues/289)



#### 2.9.0 - 10-2018
* Improved README. [#243](https://github.com/fsprojects/fantomas/issues/243)
* Bad split of chained method call expression. [#246](https://github.com/fsprojects/fantomas/issues/246)
Expand Down
8 changes: 4 additions & 4 deletions src/Fantomas.Cmd/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ open System.Reflection
[<assembly: AssemblyTitleAttribute("Fantomas")>]
[<assembly: AssemblyProductAttribute("Fantomas")>]
[<assembly: AssemblyDescriptionAttribute("Source code formatter for F#")>]
[<assembly: AssemblyVersionAttribute("2.9.1")>]
[<assembly: AssemblyFileVersionAttribute("2.9.1")>]
[<assembly: AssemblyVersionAttribute("2.9.2")>]
[<assembly: AssemblyFileVersionAttribute("2.9.2")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyTitle = "Fantomas"
let [<Literal>] AssemblyProduct = "Fantomas"
let [<Literal>] AssemblyDescription = "Source code formatter for F#"
let [<Literal>] AssemblyVersion = "2.9.1"
let [<Literal>] AssemblyFileVersion = "2.9.1"
let [<Literal>] AssemblyVersion = "2.9.2"
let [<Literal>] AssemblyFileVersion = "2.9.2"
2 changes: 1 addition & 1 deletion src/Fantomas.Cmd/Fantomas.Cmd.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<Version>2.9.1</Version>
<Version>2.9.2</Version>
<AssemblyName>dotnet-fantomas</AssemblyName>
<TargetFrameworks>net452;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.CoreGlobalTool/Fantomas.CoreGlobalTool.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework>
<ToolCommandName>fantomas</ToolCommandName>
<PackAsTool>True</PackAsTool>
<Version>2.9.1</Version>
<Version>2.9.2</Version>
<AssemblyName>fantomas-tool</AssemblyName>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas.Tests/Fantomas.Tests.fsproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>2.9.1</Version>
<Version>2.9.2</Version>
<NoWarn>FS0988</NoWarn>
<TargetFrameworks>net452;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>
Expand Down
21 changes: 21 additions & 0 deletions src/Fantomas.Tests/PreserveEOLTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -469,3 +469,24 @@ let x = 1
let y = 2
#endif
"""

[<Test>]
let ``single line comments at end of line should not added additional newline`` () =
let config = { config with PageWidth = 80 }

formatSourceString false """
type QueryOption =
| FixedQuery of string // xpath
| KeywordSearch of string // keyword

type MessageTypeQueryMeta =
{ Options: QueryOption list }
""" config
|> should equal """
type QueryOption =
| FixedQuery of string // xpath
| KeywordSearch of string // keyword

type MessageTypeQueryMeta =
{ Options : QueryOption list }
"""
8 changes: 4 additions & 4 deletions src/Fantomas/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ open System.Runtime.CompilerServices
[<assembly: AssemblyTitleAttribute("FantomasLib")>]
[<assembly: AssemblyProductAttribute("Fantomas")>]
[<assembly: AssemblyDescriptionAttribute("Source code formatter for F#")>]
[<assembly: AssemblyVersionAttribute("2.9.1")>]
[<assembly: AssemblyFileVersionAttribute("2.9.1")>]
[<assembly: AssemblyVersionAttribute("2.9.2")>]
[<assembly: AssemblyFileVersionAttribute("2.9.2")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] InternalsVisibleTo = "Fantomas.Tests"
let [<Literal>] AssemblyTitle = "FantomasLib"
let [<Literal>] AssemblyProduct = "Fantomas"
let [<Literal>] AssemblyDescription = "Source code formatter for F#"
let [<Literal>] AssemblyVersion = "2.9.1"
let [<Literal>] AssemblyFileVersion = "2.9.1"
let [<Literal>] AssemblyVersion = "2.9.2"
let [<Literal>] AssemblyFileVersion = "2.9.2"
10 changes: 7 additions & 3 deletions src/Fantomas/CodeFormatter.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ fsi.AddPrinter (fun (p : pos) -> p.ToString())
fsi.AddPrinter (fun (r : range) -> r.ToString())

"""
type T() =
let x = 123
// override private x.ToString() = ""
type QueryOption =
| FixedQuery of string // xpath
| KeywordSearch of string // keyword

type MessageTypeQueryMeta =
{ Options: QueryOption list }

"""
|> formatSrc

Expand Down
2 changes: 1 addition & 1 deletion src/Fantomas/Fantomas.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net452;netstandard2.0</TargetFrameworks>
<Version>2.9.1</Version>
<Version>2.9.2</Version>
</PropertyGroup>
<ItemGroup>
<None Include="paket.references" />
Expand Down
5 changes: 3 additions & 2 deletions src/Fantomas/TokenMatcher.fs
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,9 @@ let integrateComments isPreserveEOL compilationDefines (originalText : string) (
| Space _ :: (EOL, newTokText) :: moreNewTokens | (EOL, newTokText) :: moreNewTokens ->
addText " "
for x in commentTokensText do addText x
Debug.WriteLine "emitting newline for end of sticky-to-left comment"
addText newTokText
if not isPreserveEOL then
Debug.WriteLine "emitting newline for end of sticky-to-left comment"
addText newTokText
loop moreOrigTokens moreNewTokens
// Otherwise, skip a whitespace token and maintain the indentation
| Space _ :: moreNewTokens | moreNewTokens ->
Expand Down