Skip to content

Commit 6355b71

Browse files
committed
only one cradle should run
1 parent 9fc2093 commit 6355b71

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

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

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
531531
-- -> Action (IdeResult HscEnvEq,[FilePath])
532532
let session args@(hieYaml, _cfp, _opts, _libDir) = do
533533
ShakeExtras{ideNc} <- getShakeExtras
534-
IdeOptions{ optCheckProject = getCheckProject , optExtensions } <- getIdeOptions
534+
IdeOptions{ optExtensions } <- getIdeOptions
535535
(new_deps, old_deps) <- packageSetup args
536536

537537
-- For each component, now make a new HscEnvEq which contains the
@@ -797,22 +797,20 @@ loadSessionWithOptions recorder SessionLoadingOptions{..} rootDir = do
797797
-- before attempting to do so.
798798
ShakeExtras{restartShakeSession } <- getShakeExtras
799799
IdeOptions{ optCheckProject = getCheckProject} <- getIdeOptions
800-
returnWithVersion $ \file ->
800+
returnWithVersion $ \file -> do
801801
-- only one cradle consult at a time
802-
UnliftIO.withMVar cradleLock $ const $ do
803-
-- we need to find a way to get rid of the (files, keys)
804-
_opts@(a, b, _files, _keys) <- use_ HieYaml file
805-
-- _opts@(a, b, _files, _keys) <- getOptions file
806-
async <- UnliftIO.async $ do
802+
async <- UnliftIO.async $ UnliftIO.withMVar cradleLock $ const $ do
803+
-- we need to find a way to get rid of the (files, keys)
804+
_opts@(a, b, _files, _keys) <- use_ HieYaml file
807805
files <- liftIO $ atomically $ swapTVar targetFiles []
808806
keys <- liftIO $ atomically $ swapTVar restartKeys []
809807
_ <- useNoFile_ SessionCacheVersion
810808
liftIO $ when (notNull files || notNull keys) $ do
811809
checkProject <- getCheckProject
812810
-- think of not to restart a second time
813811
restartShakeSession VFSUnmodified "new component" (if checkProject then return (typecheckAll files) else mempty) $ pure keys
814-
UnliftIO.wait async
815-
pure $ (fmap . fmap) toAbsolutePath (a, b))
812+
pure $ (fmap . fmap) toAbsolutePath (a, b)
813+
UnliftIO.wait async)
816814

817815

818816
-- | Run the specific cradle on a specific FilePath via hie-bios.
@@ -1135,17 +1133,6 @@ type FlagsMap = Map.Map (Maybe FilePath) (HM.HashMap NormalizedFilePath (IdeResu
11351133
-- It aims to be the reverse of 'FlagsMap'.
11361134
type FilesMap = HM.HashMap NormalizedFilePath (Maybe FilePath)
11371135

1138-
-- file1 -> hie1.yaml -> (opts, deps)
1139-
-- file2 -> hie1.yaml -> (opts, deps)
1140-
-- file3 -> hie1.yaml -> (opts, deps)
1141-
-- if some new file4 should be in hie1.yaml,
1142-
-- we need to recompute the hie1.yaml
1143-
1144-
-- hieRule file
1145-
-- get corresponding hie.yaml
1146-
1147-
1148-
11491136
-- This is pristine information about a component
11501137
data RawComponentInfo = RawComponentInfo
11511138
{ rawComponentUnitId :: UnitId

0 commit comments

Comments
 (0)