Skip to content

Commit 3c5aaf2

Browse files
committed
Always add dependency files of interest ReadOnly
1 parent e896d77 commit 3c5aaf2

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ ofInterestRules recorder = do
7878
summarize (IsFOI OnDisk) = BS.singleton 1
7979
summarize (IsFOI (Modified False)) = BS.singleton 2
8080
summarize (IsFOI (Modified True)) = BS.singleton 3
81+
summarize (IsFOI ReadOnly) = BS.singleton 4
8182

8283
------------------------------------------------------------
8384
newtype GarbageCollectVar = GarbageCollectVar (Var Bool)

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,23 @@ descriptor recorder plId = (defaultPluginDescriptor plId) { pluginNotificationHa
7575
\ide vfs _ (DidChangeTextDocumentParams identifier@VersionedTextDocumentIdentifier{_uri} changes) -> liftIO $ do
7676
atomically $ updatePositionMapping ide identifier changes
7777
whenUriFile _uri $ \file -> do
78-
addFileOfInterest ide file Modified{firstOpen=False}
79-
setFileModified (cmapWithPrio LogFileStore recorder) (VFSModified vfs) ide False file
78+
let foiStatus = case getSourceFileOrigin file of
79+
FromProject -> Modified{firstOpen=True}
80+
FromDependency -> ReadOnly
81+
addFileOfInterest ide file foiStatus
82+
unless (foiStatus == ReadOnly)
83+
$ setFileModified (cmapWithPrio LogFileStore recorder) (VFSModified vfs) ide False file
8084
logDebug (ideLogger ide) $ "Modified text document: " <> getUri _uri
8185

8286
, mkPluginNotificationHandler LSP.SMethod_TextDocumentDidSave $
8387
\ide vfs _ (DidSaveTextDocumentParams TextDocumentIdentifier{_uri} _) -> liftIO $ do
8488
whenUriFile _uri $ \file -> do
85-
addFileOfInterest ide file OnDisk
86-
setFileModified (cmapWithPrio LogFileStore recorder) (VFSModified vfs) ide True file
89+
let foiStatus = case getSourceFileOrigin file of
90+
FromProject -> OnDisk
91+
FromDependency -> ReadOnly
92+
addFileOfInterest ide file foiStatus
93+
unless (foiStatus == ReadOnly)
94+
$ setFileModified (cmapWithPrio LogFileStore recorder) (VFSModified vfs) ide True file
8795
logDebug (ideLogger ide) $ "Saved text document: " <> getUri _uri
8896

8997
, mkPluginNotificationHandler LSP.SMethod_TextDocumentDidClose $

0 commit comments

Comments
 (0)