diff --git a/ghcide/src/Development/IDE/Core/OfInterest.hs b/ghcide/src/Development/IDE/Core/OfInterest.hs index 496a20a916..28649971f6 100644 --- a/ghcide/src/Development/IDE/Core/OfInterest.hs +++ b/ghcide/src/Development/IDE/Core/OfInterest.hs @@ -8,6 +8,7 @@ -- open in the editor. The rule is 'IsFileOfInterest' module Development.IDE.Core.OfInterest( ofInterestRules, + getFilesOfInterest, getFilesOfInterestUntracked, addFileOfInterest, deleteFileOfInterest, @@ -57,6 +58,11 @@ ofInterestRules = do ------------------------------------------------------------ -- Exposed API +getFilesOfInterest :: IdeState -> IO( HashMap NormalizedFilePath FileOfInterestStatus) +getFilesOfInterest state = do + OfInterestVar var <- getIdeGlobalState state + readVar var + -- | Set the files-of-interest - not usually necessary or advisable. -- The LSP client will keep this information up to date. setFilesOfInterest :: IdeState -> HashMap NormalizedFilePath FileOfInterestStatus -> IO () diff --git a/ghcide/src/Development/IDE/LSP/Notifications.hs b/ghcide/src/Development/IDE/LSP/Notifications.hs index edd58ccb5b..fca676d8da 100644 --- a/ghcide/src/Development/IDE/LSP/Notifications.hs +++ b/ghcide/src/Development/IDE/LSP/Notifications.hs @@ -26,6 +26,7 @@ import qualified Data.HashSet as S import qualified Data.Text as Text import Control.Monad.IO.Class +import qualified Data.HashMap.Strict as HM import Development.IDE.Core.FileExists (modifyFileExists, watchedGlobs) import Development.IDE.Core.FileStore (registerFileWatches, @@ -84,8 +85,15 @@ descriptor plId = (defaultPluginDescriptor plId) { pluginNotificationHandlers = -- what we do with them let msg = show fileEvents logDebug (ideLogger ide) $ "Watched file events: " <> Text.pack msg - modifyFileExists ide fileEvents - resetFileStore ide fileEvents + -- filter out files of interest, since we already know all about those + filesOfInterest <- getFilesOfInterest ide + let fileEvents' = + [ f | f@(FileEvent uri _) <- fileEvents + , Just fp <- [uriToFilePath uri] + , not $ HM.member (toNormalizedFilePath fp) filesOfInterest + ] + modifyFileExists ide fileEvents' + resetFileStore ide fileEvents' setSomethingModified ide [] msg , mkPluginNotificationHandler LSP.SWorkspaceDidChangeWorkspaceFolders $