Skip to content
Closed
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
9 changes: 2 additions & 7 deletions src/fsharp/service/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1545,11 +1545,6 @@ module internal Parser =
let tokenizer = LexFilter.LexFilter(lightSyntaxStatus, options.CompilingFsLib, Lexer.token lexargs true, lexbuf)
tokenizer.Lexer

// Adding this new-line character at the end of the source seems odd but is required for some unit tests
// Todo: fix tests
let addNewLine (source: string) =
if source.Length = 0 || not (source.[source.Length - 1] = '\n') then source + "\n" else source

let matchBraces(source, fileName, options: FSharpParsingOptions, userOpName: string) =
let delayedLogger = CapturingErrorLogger("matchBraces")
use _unwindEL = PushErrorLoggerPhaseUntilUnwind (fun _ -> delayedLogger)
Expand All @@ -1563,7 +1558,7 @@ module internal Parser =
use _unwindBP = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse

let matchingBraces = new ResizeArray<_>()
Lexhelp.usingLexbufForParsing(UnicodeLexing.StringAsLexbuf(addNewLine source), fileName) (fun lexbuf ->
Lexhelp.usingLexbufForParsing(UnicodeLexing.StringAsLexbuf(source), fileName) (fun lexbuf ->
let errHandler = ErrorHandler(false, fileName, options.ErrorSeverityOptions, source)
let lexfun = createLexerFunction fileName options lexbuf errHandler
let parenTokensBalance t1 t2 =
Expand Down Expand Up @@ -1599,7 +1594,7 @@ module internal Parser =
use unwindBP = PushThreadBuildPhaseUntilUnwind BuildPhase.Parse

let parseResult =
Lexhelp.usingLexbufForParsing(UnicodeLexing.StringAsLexbuf(addNewLine source), fileName) (fun lexbuf ->
Lexhelp.usingLexbufForParsing(UnicodeLexing.StringAsLexbuf(source), fileName) (fun lexbuf ->
let lexfun = createLexerFunction fileName options lexbuf errHandler
let isLastCompiland =
fileName.Equals(options.LastFileName, StringComparison.CurrentCultureIgnoreCase) ||
Expand Down
4 changes: 2 additions & 2 deletions tests/service/InteractiveCheckerTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let input =
let ``Test ranges - namespace`` () =
let res = parseAndExtractRanges input
printfn "Test ranges - namespace, res = %A" res
res |> shouldEqual [("N", ((4, 4), (6, 0))); ("Sample", ((4, 9), (4, 15)))]
res |> shouldEqual [("N", ((4, 4), (5, 4))); ("Sample", ((4, 9), (4, 15)))]

let input2 =
"""
Expand All @@ -97,4 +97,4 @@ let input3 =
let ``Test ranges - global namespace`` () =
let res = parseAndExtractRanges input3
printfn "Test ranges - global namespace, res = %A" res
res |> shouldEqual [("", ((4, 4), (6, 0))); ("Sample", ((4, 9), (4, 15)))]
res |> shouldEqual [("", ((4, 4), (5, 4))); ("Sample", ((4, 9), (4, 15)))]
2 changes: 1 addition & 1 deletion tests/service/StructureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let (=>) (source: string) (expectedRanges: (Range * Range) list) =
reraise()

[<Test>]
let ``empty file``() = "" => [ (1, 0, 2, 0), (1, 0, 2, 0) ]
let ``empty file``() = "" => []

[<Test>]
let ``nested module``() =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1531,17 +1531,24 @@ let x = new MyClass2(0)
[<Test>]
member public this.``AfterConstructor.5039_1``() =
AssertAutoCompleteContainsNoCoffeeBreak
[ "let someCall(x) = null"
"let xe = someCall(System.IO.StringReader()." ]
[
"""
let someCall(x) = null
let xe = someCall(System.IO.StringReader().
""" ]
"StringReader()."
[ "ReadBlock" ] // should contain (StringReader)
[ "LastIndexOfAny" ] // should not contain (String)

[<Test>]
member public this.``AfterConstructor.5039_1.CoffeeBreak``() =
AssertAutoCompleteContains
[ "let someCall(x) = null"
"let xe = someCall(System.IO.StringReader()." ]
[
"""
let someCall(x) = null
let xe = someCall(System.IO.StringReader().
"""
]
"StringReader()."
[ "ReadBlock" ] // should contain (StringReader)
[ "LastIndexOfAny" ] // should not contain (String)
Expand Down Expand Up @@ -4913,8 +4920,12 @@ let x = query { for bbbb in abbbbc(*D0*) do

[<Test>]
member this.``BadCompletionAfterQuicklyTyping.Bug130733.NowWorks``() =
let code = [ "let someCall(x) = null"
"let xe = someCall(System.IO.StringReader() "]
let code = [
"""
let someCall(x) = null
let xe = someCall(System.IO.StringReader().
"""
]
let (_, _, file) = this.CreateSingleFileProject(code)

TakeCoffeeBreak(this.VS)
Expand Down
Loading