Skip to content

Commit 4790d92

Browse files
committed
writeProgressQue with pending removal in one transaction to prevent out of order in report progress
1 parent aeef1ea commit 4790d92

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

ghcide/exe/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ main = withTelemetryRecorder $ \telemetryRecorder -> do
118118
then IDEMain.testing (cmapWithPrio LogIDEMain recorder) hlsPlugins
119119
else IDEMain.defaultArguments (cmapWithPrio LogIDEMain recorder) hlsPlugins
120120

121-
IDEMain.defaultMain (cmapWithPrio LogIDEMain recorder) arguments
121+
g (cmapWithPrio LogIDEMain recorder) arguments
122122
{ IDEMain.argsProjectRoot = Just argsCwd
123123
, IDEMain.argCommand = argsCommand
124124
, IDEMain.argsHlsPlugins = IDEMain.argsHlsPlugins arguments <> pluginDescToIdePlugins [lspRecorderPlugin]

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -990,16 +990,13 @@ indexHieFile se mod_summary srcPath !hash hf = do
990990
}
991991
-- Report the progress once we are done indexing this file
992992
post = do
993-
mdone <- atomically $ do
993+
atomically $ do
994994
-- Remove current element from pending
995995
pending <- stateTVar indexPending $
996996
dupe . HashMap.update (\pendingHash -> guard (pendingHash /= hash) $> pendingHash) srcPath
997997
modifyTVar' indexCompleted (+1)
998998
-- If we are done, report and reset completed
999-
whenMaybe (HashMap.null pending) $
1000-
swapTVar indexCompleted 0
1001-
1002-
atomically $ do
999+
mdone <- whenMaybe (HashMap.null pending) $ swapTVar indexCompleted 0
10031000
writeTQueue indexProgressThread $ do
10041001
whenJust (lspEnv se) $ \env -> LSP.runLspT env $
10051002
when (coerce $ ideTesting se) $

0 commit comments

Comments
 (0)