Skip to content

Commit

Permalink
Switch LspServer.CodeLensResolve to use async GetLatestTypeCheckResul…
Browse files Browse the repository at this point in the history
…ts so lenses wait for check to complete. Appears to fix broken code lenses in Ionide following 5.9.0 release. (ionide#852)

Co-authored-by: Beau Van Kirk <[email protected]>
  • Loading branch information
2 people authored and baronfel committed Nov 14, 2021
1 parent 9ba8e3f commit 45d289c
Showing 1 changed file with 17 additions and 27 deletions.
44 changes: 17 additions & 27 deletions src/FsAutoComplete/FsAutoComplete.Lsp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1892,35 +1892,25 @@ type FSharpLspServer(backgroundServiceEnabled: bool, state: State, lspClient: FS
| ResultOrString.Ok (options, _, lineStr) ->
try
async {
let tyResOpt =
commands.TryGetRecentTypeCheckResultsForFile(file)

return!
match tyResOpt with
| None ->
logger.warn (
Log.setMessage "CodeLensResolve - Cached typecheck results not yet available for {file}"
>> Log.addContextDestructured "file" file
)

{ p with Command = None }
|> success
|> async.Return
| Some tyRes ->
async {
let! r = Async.Catch(f arg pos tyRes lineStr data.[1] file)
let! tyRes =
commands.GetLatestTypeCheckResultsForFile(file)

match r with
| Choice1Of2 r -> return r
| Choice2Of2 e ->
logger.error (
Log.setMessage "CodeLensResolve - Child operation failed for {file}"
>> Log.addContextDestructured "file" file
>> Log.addExn e
)
logger.info (
Log.setMessage "CodeLensResolve - Cached typecheck results now available for {file}."
>> Log.addContextDestructured "file" file
)
let! r = Async.Catch(f arg pos tyRes lineStr data.[1] file)

match r with
| Choice1Of2 r -> return r
| Choice2Of2 e ->
logger.error (
Log.setMessage "CodeLensResolve - Child operation failed for {file}"
>> Log.addContextDestructured "file" file
>> Log.addExn e
)

return { p with Command = None } |> success
}
return { p with Command = None } |> success
}
with
| e ->
Expand Down

0 comments on commit 45d289c

Please sign in to comment.