Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/Core/FileStore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ getFileContents f = do
Nothing -> do
foi <- use_ IsFileOfInterest f
liftIO $ case foi of
IsFOI Modified -> getCurrentTime
IsFOI Modified{} -> getCurrentTime
_ -> do
(large,small) <- getModTime $ fromNormalizedFilePath f
pure $ internalTimeToUTCTime large small
Expand Down
5 changes: 4 additions & 1 deletion ghcide/src/Development/IDE/Core/RuleTypes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ instance NFData GetFileContents
instance Binary GetFileContents


data FileOfInterestStatus = OnDisk | Modified
data FileOfInterestStatus
= OnDisk
| Modified { firstOpen :: !Bool -- ^ was this file just opened
}
deriving (Eq, Show, Typeable, Generic)
instance Hashable FileOfInterestStatus
instance NFData FileOfInterestStatus
Expand Down
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/Core/Rules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ getHieAstRuleDefinition f hsc tmr = do

isFoi <- use_ IsFileOfInterest f
diagsWrite <- case isFoi of
IsFOI Modified -> do
IsFOI Modified{firstOpen = False} -> do
when (coerce $ ideTesting se) $
liftIO $ eventer se $ LSP.NotCustomServer $
LSP.NotificationMessage "2.0" (LSP.CustomServerMethod "ghcide/reference/ready") (toJSON $ fromNormalizedFilePath f)
Expand Down
4 changes: 2 additions & 2 deletions ghcide/src/Development/IDE/LSP/Notifications.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ setHandlersNotifications = PartialHandlers $ \WithMessage{..} x -> return x
whenUriFile _uri $ \file -> do
-- We don't know if the file actually exists, or if the contents match those on disk
-- For example, vscode restores previously unsaved contents on open
modifyFilesOfInterest ide (M.insert file Modified)
modifyFilesOfInterest ide (M.insert file Modified{firstOpen=True})
setFileModified ide False file
logInfo (ideLogger ide) $ "Opened text document: " <> getUri _uri

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

Expand Down