@@ -15,7 +15,7 @@ module Development.IDE.Core.FileStore(
15
15
makeVFSHandle ,
16
16
makeLSPVFSHandle ,
17
17
isFileOfInterestRule
18
- ,modifyFileStore ) where
18
+ ,resetFileStore ) where
19
19
20
20
import Control.Concurrent.Extra
21
21
import Control.Concurrent.STM (atomically )
@@ -31,7 +31,7 @@ import Data.Maybe
31
31
import qualified Data.Rope.UTF16 as Rope
32
32
import qualified Data.Text as T
33
33
import Data.Time
34
- import Development.IDE.Core.OfInterest (getFilesOfInterest )
34
+ import Development.IDE.Core.OfInterest (getFilesOfInterest , OfInterestVar ( .. ) )
35
35
import Development.IDE.Core.RuleTypes
36
36
import Development.IDE.Core.Shake
37
37
import Development.IDE.GHC.Orphans ()
@@ -65,7 +65,7 @@ import Language.LSP.Server hiding
65
65
import qualified Language.LSP.Server as LSP
66
66
import Language.LSP.Types (FileChangeType (FcChanged ),
67
67
FileEvent (FileEvent ),
68
- uriToFilePath )
68
+ uriToFilePath , toNormalizedFilePath )
69
69
import Language.LSP.VFS
70
70
71
71
makeVFSHandle :: IO VFSHandle
@@ -119,15 +119,20 @@ getModificationTimeRule vfs isWatched =
119
119
else return (Nothing , ([diag], Nothing ))
120
120
121
121
-- | Reset the GetModificationTime state of watched files
122
- modifyFileStore :: IdeState -> [FileEvent ] -> IO ()
123
- modifyFileStore state changes = mask $ \ _ ->
122
+ resetFileStore :: IdeState -> [FileEvent ] -> IO ()
123
+ resetFileStore ideState changes = mask $ \ _ ->
124
124
forM_ changes $ \ (FileEvent uri c) ->
125
125
case c of
126
126
FcChanged
127
127
| Just f <- uriToFilePath uri
128
128
-> do
129
- deleteValue state (GetModificationTime_ True ) (toNormalizedFilePath' f)
130
- deleteValue state (GetModificationTime_ False ) (toNormalizedFilePath' f)
129
+ -- we record FOIs document versions in all the stored values
130
+ -- so NEVER reset FOIs to avoid losing their versions
131
+ OfInterestVar foisVar <- getIdeGlobalExtras (shakeExtras ideState)
132
+ fois <- readVar foisVar
133
+ unless (HM. member (toNormalizedFilePath f) fois) $ do
134
+ deleteValue ideState (GetModificationTime_ True ) (toNormalizedFilePath' f)
135
+ deleteValue ideState (GetModificationTime_ False ) (toNormalizedFilePath' f)
131
136
_ -> pure ()
132
137
133
138
-- Dir.getModificationTime is surprisingly slow since it performs
0 commit comments