@@ -95,11 +95,12 @@ getModificationTimeRule :: VFSHandle -> Rules ()
9595getModificationTimeRule vfs =
9696 defineEarlyCutoff $ \GetModificationTime file -> do
9797 let file' = fromNormalizedFilePath file
98− let wrap time = (Just time, ([], Just $ ModificationTime time))
98+ let wrap time@(l,s) = (Just $ BS.pack $ show time, ([], Just $ ModificationTime l s))
9999 alwaysRerun
100100 mbVirtual <- liftIO $ getVirtualFile vfs $ filePathToUri' file
101101 case mbVirtual of
102− Just (virtualFileVersion -> ver) -> pure (Just $ BS.pack $ show ver, ([], Just $ VFSVersion ver))
102+ Just (virtualFileVersion -> ver) ->
103+ pure (Just $ BS.pack $ show ver, ([], Just $ VFSVersion ver))
103104 Nothing -> liftIO $ fmap wrap (getModTime file')
104105 `catch` \(e :: IOException) -> do
105106 let err | isDoesNotExistError e = "File does not exist: " ++ file'
@@ -115,11 +116,13 @@ getModificationTimeRule vfs =
115116 -- We might also want to try speeding this up on Windows at some point.
116117 -- TODO leverage DidChangeWatchedFile lsp notifications on clients that
117118 -- support them, as done for GetFileExists
118− getModTime :: FilePath -> IO BS.ByteString
119+ getModTime :: FilePath -> IO (Int,Int)
119120 getModTime f =
120121#ifdef mingw32_HOST_OS
121122 do time <- Dir.getModificationTime f
122− pure $! BS.pack $ show (toModifiedJulianDay $ utctDay time, diffTimeToPicoseconds $ utctDayTime time)
123+ let !day = toModifiedJulianDay $ utctDay time
124+ !dayTime = diffTimeToPicoseconds $ utctDayTime time
125+ pure (day, dayTime)
123126#else
124127 withCString f $ \f' ->
125128 alloca $ \secPtr ->
@@ -127,7 +130,7 @@ getModificationTimeRule vfs =
127130 Posix.throwErrnoPathIfMinus1Retry_ "getmodtime" f $ c_getModTime f' secPtr nsecPtr
128131 sec <- peek secPtr
129132 nsec <- peek nsecPtr
130− pure $! BS.pack $ show sec <> "." <> show nsec
133+ pure (fromEnum sec, fromIntegral nsec)
131134
132135-- Sadly even unix’s getFileStatus + modificationTimeHiRes is still about twice as slow
133136-- as doing the FFI call ourselves :(.