From a18a98f6f03fc8765f19ae48d5813b77f122178f Mon Sep 17 00:00:00 2001 From: jindraivanek Date: Tue, 4 Sep 2018 18:40:42 +0200 Subject: [PATCH 1/2] test --- src/Fantomas.Tests/OperatorTests.fs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Fantomas.Tests/OperatorTests.fs b/src/Fantomas.Tests/OperatorTests.fs index 08a9320014..ebc7ba3489 100644 --- a/src/Fantomas.Tests/OperatorTests.fs +++ b/src/Fantomas.Tests/OperatorTests.fs @@ -175,4 +175,13 @@ let ``should pipeline monadic bind``() = >>= strAddLong "A long argument that is ignored" "2" >>= strAddLong "A long argument that is ignored" "2" >>= strAddLong "A long argument that is ignored" "2" +""" + +[] +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 """ \ No newline at end of file From ab09f4dba5c3932e760709d66d7eeaf39f1799f2 Mon Sep 17 00:00:00 2001 From: jindraivanek Date: Tue, 4 Sep 2018 18:45:43 +0200 Subject: [PATCH 2/2] Workaround: detect missing part of tokenizer output --- src/Fantomas/TokenMatcher.fs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Fantomas/TokenMatcher.fs b/src/Fantomas/TokenMatcher.fs index f76da699c0..fdb59dedc5 100644 --- a/src/Fantomas/TokenMatcher.fs +++ b/src/Fantomas/TokenMatcher.fs @@ -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 @@ -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]) }