diff --git a/src/FsAutoComplete.Core/AdaptiveExtensions.fs b/src/FsAutoComplete.Core/AdaptiveExtensions.fs
index 9b1c91907..1927bc539 100644
--- a/src/FsAutoComplete.Core/AdaptiveExtensions.fs
+++ b/src/FsAutoComplete.Core/AdaptiveExtensions.fs
@@ -541,7 +541,7 @@ module AsyncAVal =
///
- /// Returns a new async adaptive value that adaptively applies the mapping fun tion to the given
+ /// Returns a new async adaptive value that adaptively applies the mapping function to the given
/// adaptive inputs.
///
let map (mapping: 'a -> CancellationToken -> Task<'b>) (input: asyncaval<'a>) =
@@ -573,7 +573,7 @@ module AsyncAVal =
///
- /// Returns a new async adaptive value that adaptively applies the mapping fun tion to the given
+ /// Returns a new async adaptive value that adaptively applies the mapping function to the given
/// adaptive inputs.
///
let mapAsync (mapping: 'a -> Async<'b>) (input: asyncaval<'a>) =
@@ -605,7 +605,7 @@ module AsyncAVal =
///
- /// Returns a new async adaptive value that adaptively applies the mapping fun tion to the given
+ /// Returns a new async adaptive value that adaptively applies the mapping function to the given
/// adaptive inputs.
///
let mapSync (mapping: 'a -> CancellationToken -> 'b) (input: asyncaval<'a>) =
diff --git a/src/FsAutoComplete.Core/Commands.fs b/src/FsAutoComplete.Core/Commands.fs
index c16696af4..bcccc9de4 100644
--- a/src/FsAutoComplete.Core/Commands.fs
+++ b/src/FsAutoComplete.Core/Commands.fs
@@ -1349,7 +1349,7 @@ type Commands
let text = sourceTextFactory.Create(file, ctn)
state.Files.[file] <-
- { Touched = DateTime.Now
+ { LastTouched = DateTime.Now
Source = text
Version = None }
diff --git a/src/FsAutoComplete.Core/FileSystem.fs b/src/FsAutoComplete.Core/FileSystem.fs
index 23bc067b1..266165a6f 100644
--- a/src/FsAutoComplete.Core/FileSystem.fs
+++ b/src/FsAutoComplete.Core/FileSystem.fs
@@ -332,7 +332,7 @@ type NamedText(fileName: string, str: string) =
startRange, endRange
/// create a new IFSACSourceText for this file with the given text inserted at the given range.
- member x.ModifyText(m: FSharp.Compiler.Text.Range, text: string) : Result =
+ member x.ModifyText(m: FSharp.Compiler.Text.Range, text: string) : Result =
result {
let startRange, endRange = x.SplitAt(m)
let! startText = x[startRange] |> Result.mapError (fun x -> $"startRange -> {x}")
@@ -442,8 +442,7 @@ type NamedText(fileName: string, str: string) =
member x.TryGetNextChar p = x.TryGetNextChar p
member x.PrevPos p = x.PrevPos p
member x.TryGetPrevChar p = x.TryGetPrevChar p
-
- member x.ModifyText(r, t) = x.ModifyText(r, t)
+ member x.ModifyText(r, t) = x.ModifyText(r, t) |> Result.map unbox
member x.Item
with get (m: FSharp.Compiler.Text.Range) = x.Item m
@@ -712,7 +711,6 @@ type ISourceTextFactory =
type NamedTextFactory() =
interface ISourceTextFactory with
member this.Create(fileName: string, text: string) : IFSACSourceText = NamedText(fileName, text)
-
member this.Create(fileName: string, stream: Stream) : ValueTask =
valueTask {
use reader = new StreamReader(stream)
@@ -734,14 +732,15 @@ type RoslynSourceTextFactory() =
|> ValueTask.FromResult
module File =
- let getLastWriteTimeOrDefaultNow (path: string) =
+ let getLastWriteTimeOrDefaultNow (path: string) =
+ let path = UMX.untag path
if File.Exists path then
File.GetLastWriteTimeUtc path
else
DateTime.UtcNow
type VolatileFile =
- { Touched: DateTime
+ { LastTouched: DateTime
Source: IFSACSourceText
Version: int option }
@@ -751,13 +750,12 @@ type VolatileFile =
member this.SetSource(source) = { this with Source = source }
/// Updates the Touched value
- member this.SetTouched touched = { this with Touched = touched }
+ member this.SetLastTouched touched = { this with LastTouched = touched }
/// Updates the Touched value attempting to use the file on disk's GetLastWriteTimeUtc otherwise uses DateTime.UtcNow.
member this.UpdateTouched() =
- let path = UMX.untag this.Source.FileName
- let dt = File.getLastWriteTimeOrDefaultNow path
- this.SetTouched dt
+ let dt = File.getLastWriteTimeOrDefaultNow this.Source.FileName
+ this.SetLastTouched dt
/// Helper method to create a VolatileFile
@@ -765,11 +763,11 @@ type VolatileFile =
let touched =
match touched with
| Some t -> t
- | None -> File.getLastWriteTimeOrDefaultNow source.RawFileName
+ | None -> File.getLastWriteTimeOrDefaultNow source.FileName
{ Source = source
Version = version
- Touched = touched }
+ LastTouched = touched }
type FileSystem(actualFs: IFileSystem, tryFindFile: string -> VolatileFile option) =
let fsLogger = LogProvider.getLoggerByName "FileSystem"
@@ -834,7 +832,7 @@ type FileSystem(actualFs: IFileSystem, tryFindFile: string -> Volatil
filename
|> Utils.normalizePath
|> tryFindFile
- |> Option.map (fun f -> f.Touched)
+ |> Option.map (fun f -> f.LastTouched)
|> Option.defaultWith (fun () -> actualFs.GetLastWriteTimeShim filename)
// fsLogger.debug (
diff --git a/src/FsAutoComplete.Core/State.fs b/src/FsAutoComplete.Core/State.fs
index 622b00d3d..ba99ea8a1 100644
--- a/src/FsAutoComplete.Core/State.fs
+++ b/src/FsAutoComplete.Core/State.fs
@@ -187,7 +187,7 @@ type State =
|> Option.map (fun opts ->
x.Files.[file] <-
{ Source = text
- Touched = DateTime.Now
+ LastTouched = DateTime.Now
Version = None }
opts)
@@ -219,7 +219,7 @@ type State =
member x.AddFileTextAndCheckerOptions(file: string, text: IFSACSourceText, opts, version) =
let fileState =
{ Source = text
- Touched = DateTime.Now
+ LastTouched = DateTime.Now
Version = version }
x.Files.[file] <- fileState
@@ -228,7 +228,7 @@ type State =
member x.AddFileText(file: string, text: IFSACSourceText, version) =
let fileState =
{ Source = text
- Touched = DateTime.Now
+ LastTouched = DateTime.Now
Version = version }
x.Files.[file] <- fileState
diff --git a/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs b/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs
index b6e439df2..032d8470b 100644
--- a/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs
+++ b/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs
@@ -331,7 +331,7 @@ type AdaptiveFSharpLspServer
match parseAndCheck.GetCheckResults.ImplementationFile with
| Some tast ->
- do! Async.SwitchToNewThread()
+ // do! Async.SwitchToNewThread()
let res =
Commands.analyzerHandler (
@@ -843,7 +843,7 @@ type AdaptiveFSharpLspServer
logger.debug (
Log.setMessage "TextChanged for file : {fileName} {touched} {version}"
>> Log.addContextDestructured "fileName" v.FileName
- >> Log.addContextDestructured "touched" v.Touched
+ >> Log.addContextDestructured "touched" v.LastTouched
>> Log.addContextDestructured "version" v.Version
)
@@ -936,7 +936,7 @@ type AdaptiveFSharpLspServer
else
let inline getSourceFromFile untaggedFile =
async {
- do! Async.SwitchToNewThread()
+ // do! Async.SwitchToNewThread()
use s = File.OpenRead(untaggedFile)
return! sourceTextFactory.Create(localPath, s) |> Async.AwaitValueTask
}
@@ -947,7 +947,7 @@ type AdaptiveFSharpLspServer
let! source = getSourceFromFile untagged |> AsyncAVal.ofAsync
let file =
- { Touched = lastWriteTime
+ { LastTouched = lastWriteTime
Source = source
Version = None }
@@ -993,8 +993,6 @@ type AdaptiveFSharpLspServer
let forceFindOpenFile filePath =
findFileInOpenFiles filePath |> AVal.force
-
-
let forceFindOpenFileOrRead file =
asyncOption {
@@ -1029,7 +1027,6 @@ type AdaptiveFSharpLspServer
// flattening openFilesWithChanges makes this check a lot quicker as it's not needing to recalculate each value.
fileshimChanges |> AMap.force |> HashMap.tryFind file
- // |> Option.orElseWith(fun () -> try (getCachedSourceFiles file |> AsyncAVal.force).Task.GetAwaiter().GetResult() with _ -> None)
FSharp.Compiler.IO.FileSystemAutoOpens.FileSystem <-
FileSystem(FSharp.Compiler.IO.FileSystemAutoOpens.FileSystem, filesystemShim)
@@ -1176,7 +1173,7 @@ type AdaptiveFSharpLspServer
Log.setMessage "Getting typecheck results for {file} - {hash} - {date}"
>> Log.addContextDestructured "file" file.Source.FileName
>> Log.addContextDestructured "hash" (file.Source.GetHashCode())
- >> Log.addContextDestructured "date" (file.Touched)
+ >> Log.addContextDestructured "date" (file.LastTouched)
)
let! ct = Async.CancellationToken