Skip to content

Commit 4b85e2a

Browse files
committed
fix progress
1 parent 4c044b4 commit 4b85e2a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ghcide/src/Development/IDE/Core/Compile.hs

+7-7
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ import Data.Unique
115115
import GHC.Fingerprint
116116
import Data.Coerce
117117
import Data.Aeson (toJSON)
118+
import Data.Tuple.Extra (dupe)
118119

119120
-- | Given a string buffer, return the string (after preprocessing) and the 'ParsedModule'.
120121
parseModule
@@ -572,13 +573,12 @@ indexHieFile se mod_summary srcPath hash hf = atomically $ do
572573
post tok = do
573574
mdone <- atomically $ do
574575
-- Remove current element from pending
575-
modifyTVar' indexPending $ HashMap.update (\pendingHash -> guard (pendingHash /= hash) $> pendingHash) srcPath
576-
pending <- readTVar indexPending
577-
if HashMap.null pending
578-
then Just <$> swapTVar indexCompleted 0
579-
else do
580-
modifyTVar' indexCompleted (+1)
581-
pure Nothing
576+
pending <- stateTVar indexPending $
577+
dupe . HashMap.update (\pendingHash -> guard (pendingHash /= hash) $> pendingHash) srcPath
578+
modifyTVar' indexCompleted (+1)
579+
-- If we are done, report and reset completed
580+
whenMaybe (HashMap.null pending) $
581+
swapTVar indexCompleted 0
582582
when (coerce $ ideTesting se) $
583583
eventer se $ LSP.NotCustomServer $
584584
LSP.NotificationMessage "2.0" (LSP.CustomServerMethod "ghcide/reference/ready") (toJSON $ fromNormalizedFilePath srcPath)

0 commit comments

Comments
 (0)