ionide / FsAutoComplete

F# language server using Language Server Protocol
Other
389 stars 151 forks source link

fixing caching of cancelled cached tasks #1221

Closed TheAngryByrd closed 5 months ago

TheAngryByrd commented 5 months ago

Primer

The way the AsyncAdaptive is implemented using ref-counting for tasks that depend on tasks. So if a dependent task (let's say getting a type signature hint) asks for a currently running task's result (like a typecheck) but it isn't finished, we create a TaskCompletionSource and transfer state to it when the "real" task is finished. This allows us to have to have many dependent sources still awaiting the typecheck (like say a codefix) but allows us to cancel the hint request if the user's mouse moves away.

Main problem is we were caching those cancelled tasks while the real task may still be running. Since no updates happened, Adaptive wouldn't mark the dependent tree out of date and forever getting "Task was cancelled" in places we should recompute.