diff --git a/src/FsAutoComplete.Core/CompilerServiceInterface.fs b/src/FsAutoComplete.Core/CompilerServiceInterface.fs index b0a3a9bf4..a75bf8fb9 100644 --- a/src/FsAutoComplete.Core/CompilerServiceInterface.fs +++ b/src/FsAutoComplete.Core/CompilerServiceInterface.fs @@ -41,7 +41,6 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe let mutable lastCheckResults: IMemoryCache = memoryCache () - let checkerLogger = LogProvider.getLoggerByName "Checker" let optsLogger = LogProvider.getLoggerByName "Opts" @@ -244,6 +243,8 @@ type FSharpCompilerServiceChecker(hasAnalyzers, typecheckCacheSize, parallelRefe member __.ScriptTypecheckRequirementsChanged = scriptTypecheckRequirementsChanged.Publish + member _.RemoveFileFromCache(file: string) = lastCheckResults.Remove(file) + /// This function is called when the entire environment is known to have changed for reasons not encoded in the ProjectOptions of any project/compilation. member _.ClearCaches() = lastCheckResults.Dispose() diff --git a/src/FsAutoComplete.Core/CompilerServiceInterface.fsi b/src/FsAutoComplete.Core/CompilerServiceInterface.fsi index c5371f78e..c7db49506 100644 --- a/src/FsAutoComplete.Core/CompilerServiceInterface.fsi +++ b/src/FsAutoComplete.Core/CompilerServiceInterface.fsi @@ -30,6 +30,9 @@ type FSharpCompilerServiceChecker = file: string * source: ISourceText * tfm: FSIRefs.TFM -> Async member ScriptTypecheckRequirementsChanged: IEvent + + member RemoveFileFromCache: file: string -> unit + /// This function is called when the entire environment is known to have changed for reasons not encoded in the ProjectOptions of any project/compilation. member ClearCaches: unit -> unit diff --git a/src/FsAutoComplete/LspServers/AdaptiveServerState.fs b/src/FsAutoComplete/LspServers/AdaptiveServerState.fs index 11c2daa98..a7af4ec7b 100644 --- a/src/FsAutoComplete/LspServers/AdaptiveServerState.fs +++ b/src/FsAutoComplete/LspServers/AdaptiveServerState.fs @@ -1814,6 +1814,8 @@ type AdaptiveState(lspClient: FSharpLspClient, sourceTextFactory: ISourceTextFac |> AsyncAVal.forceAsync + (AVal.force checker).RemoveFileFromCache(filePath) + transact (fun () -> openFiles.Remove filePath |> ignore