Skip to content

Commit 818a183

Browse files
committed
WIP wait for it
1 parent 8c0a466 commit 818a183

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ghcide/src/Development/IDE/Main.hs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module Development.IDE.Main
55
) where
66
import Control.Concurrent.Extra (newLock, readVar,
77
withLock)
8+
import Control.Concurrent.STM
89
import Control.Exception.Safe (Exception (displayException),
910
catchAny)
1011
import Control.Monad.Extra (concatMapM, unless,
@@ -40,8 +41,9 @@ import Development.IDE.Core.RuleTypes (GenerateCore (GenerateCo
4041
import Development.IDE.Core.Rules (GhcSessionIO (GhcSessionIO),
4142
mainRule)
4243
import Development.IDE.Core.Service (initialise, runAction)
43-
import Development.IDE.Core.Shake (IdeState (shakeExtras),
44-
ShakeExtras (state),
44+
import Development.IDE.Core.Shake (HieDbWriter (indexPending),
45+
IdeState (shakeExtras),
46+
ShakeExtras (hiedbWriter, state),
4547
toKnownFiles,
4648
useNoFile_, uses)
4749
import Development.IDE.Core.Tracing (measureMemory)
@@ -282,6 +284,13 @@ defaultMain Arguments{..} = do
282284
uses GetModIfaceFromDiskAndIndex $ toList allKnownTargets
283285
putStrLn dbLoc
284286
let nfailures = length $ filter isNothing results
287+
let pending = indexPending $ hiedbWriter $ shakeExtras ide
288+
289+
hPutStrLn stderr "Waiting for indexing..."
290+
atomically $ do
291+
n <- readTVar pending
292+
unless (HashMap.size n == 0) retry
293+
285294
unless (nfailures == 0) $ exitWith $ ExitFailure nfailures
286295
Db dir opts cmd -> do
287296
dbLoc <- getHieDbLoc dir

0 commit comments

Comments
 (0)