From 400507d3faade5284dd68d37f520607993c7c0d7 Mon Sep 17 00:00:00 2001 From: TIHan Date: Mon, 17 Jun 2019 19:07:24 -0700 Subject: [PATCH 1/2] Fixed line directive ranges when not applying a line directive --- src/fsharp/lex.fsl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/fsharp/lex.fsl b/src/fsharp/lex.fsl index 0af96d71c9a..c32c9a641b6 100644 --- a/src/fsharp/lex.fsl +++ b/src/fsharp/lex.fsl @@ -524,10 +524,14 @@ rule token args skip = parse // Construct the new position if args.applyLineDirectives then lexbuf.EndPos <- pos.ApplyLineDirective((match file with Some f -> fileIndexOfFile f | None -> pos.FileIndex), line) - + else + // add a newline when we don't apply a directive since we consumed a newline getting here + newline lexbuf token args skip lexbuf - else - if not skip then (HASH_LINE (LexCont.Token !args.ifdefStack)) else token args skip lexbuf } + else + // add a newline when we don't apply a directive since we consumed a newline getting here + newline lexbuf + (HASH_LINE (LexCont.Token !args.ifdefStack)) } | "<@" { checkExprOp lexbuf; LQUOTE ("<@ @>", false) } | "<@@" { checkExprOp lexbuf; LQUOTE ("<@@ @@>", true) } From 46e15b33cceff468fb2293ffe710c6a44a9d6c12 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Mon, 17 Jun 2019 19:49:08 -0700 Subject: [PATCH 2/2] Update ProjectAnalysisTests.fs --- tests/service/ProjectAnalysisTests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/service/ProjectAnalysisTests.fs b/tests/service/ProjectAnalysisTests.fs index 16ef433e691..c9635c70830 100644 --- a/tests/service/ProjectAnalysisTests.fs +++ b/tests/service/ProjectAnalysisTests.fs @@ -5291,7 +5291,7 @@ let ``Test line directives in foreground analysis`` () = // see https://github.c for e in checkResults1.Errors do printfn "ProjectLineDirectives checkResults1 error file: <<<%s>>>" e.FileName - [ for e in checkResults1.Errors -> e.StartLineAlternate, e.EndLineAlternate, e.FileName ] |> shouldEqual [(4, 4, ProjectLineDirectives.fileName1)] + [ for e in checkResults1.Errors -> e.StartLineAlternate, e.EndLineAlternate, e.FileName ] |> shouldEqual [(5, 5, ProjectLineDirectives.fileName1)] //------------------------------------------------------