diff --git a/src/Development/IDE/State/Service.hs b/src/Development/IDE/State/Service.hs index ff0e173a..6d83cd8b 100644 --- a/src/Development/IDE/State/Service.hs +++ b/src/Development/IDE/State/Service.hs @@ -13,7 +13,7 @@ module Development.IDE.State.Service( getServiceEnv, IdeState, initialise, shutdown, runAction, runActions, - setFilesOfInterest, + setFilesOfInterest, modifyFilesOfInterest, writeProfile, getDiagnostics, unsafeClearDiagnostics, logDebug, logSeriousError @@ -26,6 +26,8 @@ import Development.IDE.State.FileStore import qualified Development.IDE.Logger as Logger import Data.Set (Set) import qualified Data.Set as Set +import qualified Data.Text as T +import Data.Tuple.Extra import Development.IDE.Functions.GHCError import Development.IDE.Types.Diagnostics (NormalizedFilePath) import Development.Shake hiding (Diagnostic, Env, newCache) @@ -109,12 +111,13 @@ runActions x = join . shakeRun x -- | Set the files-of-interest which will be built and kept-up-to-date. setFilesOfInterest :: IdeState -> Set NormalizedFilePath -> IO () -setFilesOfInterest state files = do - Env{..} <- getIdeGlobalState state - -- update vars synchronously - modifyVar_ envOfInterestVar $ const $ return files +setFilesOfInterest state files = modifyFilesOfInterest state (const files) - -- run shake to update results regarding the files of interest +modifyFilesOfInterest :: IdeState -> (Set NormalizedFilePath -> Set NormalizedFilePath) -> IO () +modifyFilesOfInterest state f = do + Env{..} <- getIdeGlobalState state + files <- modifyVar envOfInterestVar $ pure . dupe . f + logDebug state $ "Set files of interest to: " <> T.pack (show $ Set.toList files) void $ shakeRun state [] getServiceEnv :: Action Env