@@ -9,10 +9,6 @@ open Microsoft.FSharp.Compiler
99open Microsoft.FSharp .Compiler .Ast
1010open Microsoft.FSharp .Compiler .SourceCodeServices
1111
12- type CheckResults =
13- | Readyof ( FSharpParseFileResults * FSharpCheckFileResults ) option
14- | StillRunningof Async <( FSharpParseFileResults * FSharpCheckFileResults ) option >
15-
1612type FSharpChecker with
1713member checker.ParseDocument ( document : Document , parsingOptions : FSharpParsingOptions , sourceText : string , userOpName : string ) =
1814asyncMaybe {
@@ -35,15 +31,14 @@ type FSharpChecker with
3531 Some( parseResults, checkFileResults)
3632}
3733
38- let tryGetFreshResultsWithTimeout () : Async < CheckResults > =
39- async {
40- try
41- let! worker = Async.StartChild( parseAndCheckFile, 2000 )
42- let! result = worker
43- return Ready result
44- with: ? TimeoutException ->
45- return StillRunning parseAndCheckFile
46- }
34+ let tryGetFreshResultsWithTimeout () =
35+ async {
36+ let! worker = Async.StartChild( parseAndCheckFile, millisecondsTimeout= Settings.LanguageServicePerformance.TimeUntilStaleCompletion)
37+ try
38+ return ! worker
39+ with: ? TimeoutException ->
40+ return None// worker is cancelled at this point, we cannot return it and wait its completion anymore
41+ }
4742
4843let bindParsedInput ( results : ( FSharpParseFileResults * FSharpCheckFileResults )option ) =
4944match resultswith
@@ -59,18 +54,20 @@ type FSharpChecker with
5954
6055let! results =
6156match freshResultswith
62- | Ready x-> async.Returnx
63- | StillRunning worker ->
57+ | Some x-> async.Return( Some x )
58+ | None ->
6459async {
6560match checker.TryGetRecentCheckResultsForFile( filePath, options) with
6661| Some( parseResults, checkFileResults, _) ->
6762return Some( parseResults, checkFileResults)
6863| None->
69- return ! worker
64+ return ! parseAndCheckFile
7065}
7166return bindParsedInput results
72- }
73- else parseAndCheckFile|> Async.map bindParsedInput
67+ else
68+ let! results = parseAndCheckFile
69+ return bindParsedInput results
70+ }
7471
7572
7673member checker.ParseAndCheckDocument ( document : Document , options : FSharpProjectOptions , allowStaleResults : bool , userOpName : string , ? sourceText : SourceText ) =