Skip to content

Commit d87a5db

Browse files
wz1000mergify[bot]
andauthored
Index files on first open (#1358)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent dcd8299 commit d87a5db

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ getFileContents f = do
179179
Nothing -> do
180180
foi <- use_ IsFileOfInterest f
181181
liftIO $ case foi of
182-
IsFOI Modified -> getCurrentTime
182+
IsFOI Modified{} -> getCurrentTime
183183
_ -> do
184184
(large,small) <- getModTime $ fromNormalizedFilePath f
185185
pure $ internalTimeToUTCTime large small

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,10 @@ instance NFData GetFileContents
296296
instance Binary GetFileContents
297297

298298

299-
data FileOfInterestStatus = OnDisk | Modified
299+
data FileOfInterestStatus
300+
= OnDisk
301+
| Modified { firstOpen :: !Bool -- ^ was this file just opened
302+
}
300303
deriving (Eq, Show, Typeable, Generic)
301304
instance Hashable FileOfInterestStatus
302305
instance NFData FileOfInterestStatus

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ getHieAstRuleDefinition f hsc tmr = do
593593

594594
isFoi <- use_ IsFileOfInterest f
595595
diagsWrite <- case isFoi of
596-
IsFOI Modified -> do
596+
IsFOI Modified{firstOpen = False} -> do
597597
when (coerce $ ideTesting se) $
598598
liftIO $ eventer se $ LSP.NotCustomServer $
599599
LSP.NotificationMessage "2.0" (LSP.CustomServerMethod "ghcide/reference/ready") (toJSON $ fromNormalizedFilePath f)

ghcide/src/Development/IDE/LSP/Notifications.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ setHandlersNotifications = PartialHandlers $ \WithMessage{..} x -> return x
4747
whenUriFile _uri $ \file -> do
4848
-- We don't know if the file actually exists, or if the contents match those on disk
4949
-- For example, vscode restores previously unsaved contents on open
50-
modifyFilesOfInterest ide (M.insert file Modified)
50+
modifyFilesOfInterest ide (M.insert file Modified{firstOpen=True})
5151
setFileModified ide False file
5252
logInfo (ideLogger ide) $ "Opened text document: " <> getUri _uri
5353

5454
,LSP.didChangeTextDocumentNotificationHandler = withNotification (LSP.didChangeTextDocumentNotificationHandler x) $
5555
\_ ide (DidChangeTextDocumentParams identifier@VersionedTextDocumentIdentifier{_uri} changes) -> do
5656
updatePositionMapping ide identifier changes
5757
whenUriFile _uri $ \file -> do
58-
modifyFilesOfInterest ide (M.insert file Modified)
58+
modifyFilesOfInterest ide (M.insert file Modified{firstOpen=False})
5959
setFileModified ide False file
6060
logInfo (ideLogger ide) $ "Modified text document: " <> getUri _uri
6161

0 commit comments

Comments
 (0)