From 4b85e2a3c6d8fbd5e500c290e421f610ac90f7c5 Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Mon, 18 Jan 2021 04:44:38 +0530 Subject: [PATCH] fix progress --- ghcide/src/Development/IDE/Core/Compile.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ghcide/src/Development/IDE/Core/Compile.hs b/ghcide/src/Development/IDE/Core/Compile.hs index cbce4e13243..51766f06f01 100644 --- a/ghcide/src/Development/IDE/Core/Compile.hs +++ b/ghcide/src/Development/IDE/Core/Compile.hs @@ -115,6 +115,7 @@ import Data.Unique import GHC.Fingerprint import Data.Coerce import Data.Aeson (toJSON) +import Data.Tuple.Extra (dupe) -- | Given a string buffer, return the string (after preprocessing) and the 'ParsedModule'. parseModule @@ -572,13 +573,12 @@ indexHieFile se mod_summary srcPath hash hf = atomically $ do post tok = do mdone <- atomically $ do -- Remove current element from pending - modifyTVar' indexPending $ HashMap.update (\pendingHash -> guard (pendingHash /= hash) $> pendingHash) srcPath - pending <- readTVar indexPending - if HashMap.null pending - then Just <$> swapTVar indexCompleted 0 - else do - modifyTVar' indexCompleted (+1) - pure Nothing + pending <- stateTVar indexPending $ + dupe . HashMap.update (\pendingHash -> guard (pendingHash /= hash) $> pendingHash) srcPath + modifyTVar' indexCompleted (+1) + -- If we are done, report and reset completed + whenMaybe (HashMap.null pending) $ + swapTVar indexCompleted 0 when (coerce $ ideTesting se) $ eventer se $ LSP.NotCustomServer $ LSP.NotificationMessage "2.0" (LSP.CustomServerMethod "ghcide/reference/ready") (toJSON $ fromNormalizedFilePath srcPath)