Skip to content

Commit f31df52

Browse files
pepeiborramergify[bot]jneira
authored
Avoid creating IsFileOfInterest keys for non workspace files (#1661)
* Avoid creating IsFileOfInterest keys for non workspace files * Only add the IsFileOfInterest dependency when needed * Clarify logic * fixup! Clarify logic Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Javier Neira <atreyu.bbb@gmail.com>
1 parent 2d1a588 commit f31df52

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ghcide/src/Development/IDE/Core/FileStore.hs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import qualified Development.IDE.Types.Logger as L
6767

6868
import qualified Data.Binary as B
6969
import qualified Data.ByteString.Lazy as LBS
70+
import Development.IDE.Core.IdeConfiguration (isWorkspaceFile)
7071
import Language.LSP.Server hiding
7172
(getVirtualFile)
7273
import qualified Language.LSP.Server as LSP
@@ -127,16 +128,23 @@ getModificationTimeImpl vfs isWatched missingFileDiags file = do
127128
let file' = fromNormalizedFilePath file
128129
let wrap time@(l,s) = (Just $ LBS.toStrict $ B.encode time, ([], Just $ ModificationTime l s))
129130
mbVirtual <- liftIO $ getVirtualFile vfs $ filePathToUri' file
130-
-- we use 'getVirtualFile' to discriminate FOIs so make that
131-
-- dependency explicit by using the IsFileOfInterest rule
132-
_ <- use_ IsFileOfInterest file
133131
case mbVirtual of
134132
Just (virtualFileVersion -> ver) -> do
135133
alwaysRerun
136134
pure (Just $ LBS.toStrict $ B.encode ver, ([], Just $ VFSVersion ver))
137135
Nothing -> do
138136
isWF <- isWatched file
139-
unless (isWF || isInterface file) alwaysRerun
137+
if isWF
138+
then -- the file is watched so we can rely on FileWatched notifications,
139+
-- but also need a dependency on IsFileOfInterest to reinstall
140+
-- alwaysRerun when the file becomes VFS
141+
void (use_ IsFileOfInterest file)
142+
else if isInterface file
143+
then -- interface files are tracked specially using the closed world assumption
144+
pure ()
145+
else -- in all other cases we will need to freshly check the file system
146+
alwaysRerun
147+
140148
liftIO $ fmap wrap (getModTime file')
141149
`catch` \(e :: IOException) -> do
142150
let err | isDoesNotExistError e = "File does not exist: " ++ file'

0 commit comments

Comments
 (0)