Skip to content

Commit 98999f5

Browse files
committed
restart the shake if cabal file changed
1 parent 24269f6 commit 98999f5

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,8 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
840840
-- cleanup error loading files and cradle files
841841
clearErrorLoadingFiles sessionState
842842
clearCradleFiles sessionState
843+
cacheKey <- invalidateShakeCache
844+
restartShakeSession VFSUnmodified "didSessionLoadingPreferenceConfigChange" [] (return [cacheKey])
843845

844846
v <- atomically $ STM.lookup hieYaml (fileToFlags sessionState)
845847
case v >>= HM.lookup (toNormalizedFilePath' file) of
@@ -870,20 +872,17 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir que = do
870872
-- at a time. Therefore the IORef contains the currently running cradle, if we try
871873
-- to get some more options then we wait for the currently running action to finish
872874
-- before attempting to do so.
873-
let getOptions :: FilePath -> IO ()
874-
getOptions file = do
875-
let ncfp = toNormalizedFilePath' file
876-
cachedHieYamlLocation <- atomically $ STM.lookup ncfp (filesMap sessionState)
877-
hieYaml <- cradleLoc file
878-
let hieLoc = join cachedHieYamlLocation <|> hieYaml
879-
sessionOpts (hieLoc, file) `Safe.catch` handleSessionError sessionState hieLoc file
880875

881876
let getOptionsLoop :: IO ()
882877
getOptionsLoop = do
883878
-- Get the next file to load
884-
absFile <- atomically $ S.readQueue (pendingFileSet sessionState)
885-
logWith recorder Debug (LogGetOptionsLoop absFile)
886-
getOptions absFile
879+
file <- atomically $ S.readQueue (pendingFileSet sessionState)
880+
logWith recorder Debug (LogGetOptionsLoop file)
881+
let ncfp = toNormalizedFilePath' file
882+
cachedHieYamlLocation <- join <$> atomically (STM.lookup ncfp (filesMap sessionState))
883+
hieYaml <- cradleLoc file
884+
let hieLoc = cachedHieYamlLocation <|> hieYaml
885+
sessionOpts (hieLoc, file) `Safe.catch` handleSessionError sessionState hieLoc file
887886
getOptionsLoop
888887

889888
-- | Given a file, this function will return the HscEnv and the dependencies

0 commit comments

Comments
 (0)