@@ -19,7 +19,7 @@ module Development.IDE.Core.FileStore(
1919 resetInterfaceStore ,
2020 getModificationTimeImpl ,
2121 addIdeGlobal ,
22- getFileContentsRule ,
22+ getFileContentsImpl
2323 ) where
2424
2525import Control.Concurrent.Extra
@@ -71,6 +71,7 @@ import Language.LSP.Server hiding
7171import qualified Language.LSP.Server as LSP
7272import Language.LSP.Types (FileChangeType (FcChanged ),
7373 FileEvent (FileEvent ),
74+ NormalizedFilePath (NormalizedFilePath ),
7475 toNormalizedFilePath ,
7576 uriToFilePath )
7677import Language.LSP.VFS
@@ -209,16 +210,21 @@ internalTimeToUTCTime large small =
209210#endif
210211
211212getFileContentsRule :: VFSHandle -> Rules ()
212- getFileContentsRule vfs =
213- define $ \ GetFileContents file -> do
214- -- need to depend on modification time to introduce a dependency with Cutoff
215- time <- use_ GetModificationTime file
216- res <- liftIO $ ideTryIOException file $ do
217- mbVirtual <- getVirtualFile vfs $ filePathToUri' file
218- pure $ Rope. toText . _text <$> mbVirtual
219- case res of
220- Left err -> return ([err], Nothing )
221- Right contents -> return ([] , Just (time, contents))
213+ getFileContentsRule vfs = define $ \ GetFileContents file -> getFileContentsImpl vfs file
214+
215+ getFileContentsImpl
216+ :: VFSHandle
217+ -> NormalizedFilePath
218+ -> Action ([FileDiagnostic ], Maybe (FileVersion , Maybe T. Text ))
219+ getFileContentsImpl vfs file = do
220+ -- need to depend on modification time to introduce a dependency with Cutoff
221+ time <- use_ GetModificationTime file
222+ res <- liftIO $ ideTryIOException file $ do
223+ mbVirtual <- getVirtualFile vfs $ filePathToUri' file
224+ pure $ Rope. toText . _text <$> mbVirtual
225+ case res of
226+ Left err -> return ([err], Nothing )
227+ Right contents -> return ([] , Just (time, contents))
222228
223229ideTryIOException :: NormalizedFilePath -> IO a -> IO (Either FileDiagnostic a )
224230ideTryIOException fp act =
0 commit comments