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 291 #293

Merged
merged 4 commits into from
Sep 10, 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
11 changes: 10 additions & 1 deletion src/Fantomas.Tests/OperatorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,18 @@ let ``should pipeline monadic bind``() =
>>= strAddLong "A long argument that is ignored" "2"
"""

[<Test>]
let ``should keep >>.~ operator``() =
formatSourceString false """let (>>.~) (g : int) (h : int) : int = g + h
let output = 2 >>.~ 3
""" config
|> should equal """let (>>.~) (g : int) (h : int) : int = g + h
let output = 2 >>.~ 3
"""

[<Test>]
let ``should not add newline before = operator after |>``() =
formatSourceString false """1 |> max 0 = 1""" config
|> should equal """1
|> max 0 = 1
"""
"""
6 changes: 6 additions & 0 deletions src/Fantomas/TokenMatcher.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ let tokenize defines (content : string) =
for (i, line) in lines |> Seq.zip [1..lines.Length] do
let lineTokenizer = sourceTokenizer.CreateLineTokenizer line
let finLine = ref false
let mutable lastColumn = 0
while not !finLine do
let tok, newLexState = lineTokenizer.ScanToken(!lexState)
lexState := newLexState
Expand All @@ -40,6 +41,11 @@ let tokenize defines (content : string) =
yield (EOL, Environment.NewLine)
finLine := true
| Some t ->
if lastColumn + 1 < t.LeftColumn then
// workaround for cases where tokenizer dont output "delayed" part of operator after ">."
// See https://github.com/fsharp/FSharp.Compiler.Service/issues/874
yield (Tok({ t with TokenName="DELAYED" }, i), line.[lastColumn+1..t.LeftColumn-1])
lastColumn <- t.RightColumn
yield (Tok(t, i), line.[t.LeftColumn..t.RightColumn])
}

Expand Down