Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid double rebuilds for FOIs #2266

Merged
merged 1 commit into from Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions ghcide/src/Development/IDE/Core/OfInterest.hs
Expand Up @@ -8,6 +8,7 @@
-- open in the editor. The rule is 'IsFileOfInterest'
module Development.IDE.Core.OfInterest(
ofInterestRules,
getFilesOfInterest,
getFilesOfInterestUntracked,
addFileOfInterest,
deleteFileOfInterest,
Expand Down Expand Up @@ -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 ()
Expand Down
12 changes: 10 additions & 2 deletions ghcide/src/Development/IDE/LSP/Notifications.hs
Expand Up @@ -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,
Expand Down Expand Up @@ -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 $
Expand Down