Skip to content

Commit d07c06f

Browse files
committed
always send progress
1 parent bffdb6a commit d07c06f

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import Control.Concurrent.STM.Stats (TVar, atomically,
2424
atomicallyNamed, modifyTVar',
2525
newTVarIO, readTVar, retry)
2626
import Control.Concurrent.Strict (modifyVar_, newBarrier, newVar,
27-
signalBarrier, threadDelay,
28-
waitBarrier)
27+
signalBarrier, threadDelay)
2928
import Control.Monad.Extra hiding (loop)
3029
import Control.Monad.IO.Class
3130
import Control.Monad.Trans.Class (lift)
@@ -212,15 +211,18 @@ withProgressDummy ::
212211
((ProgressAmount -> m ()) -> m a) ->
213212
m a
214213
withProgressDummy title _ _ f = do
215-
t <- L.ProgressToken . L.InR . T.pack . show . hashUnique <$> liftIO newUnique
216-
r <- liftIO newBarrier
217-
_ <- sendRequest SMethod_WindowWorkDoneProgressCreate (WorkDoneProgressCreateParams t) $
218-
\_ -> liftIO $ signalBarrier r ()
219-
-- liftIO $ waitBarrier r
220-
sendProgressReport t $ WorkDoneProgressBegin L.AString title Nothing Nothing Nothing
221-
f (const $ return ()) `UE.finally` sendProgressReport t (WorkDoneProgressEnd L.AString Nothing)
214+
UE.bracket start end $ \_ ->
215+
f (const $ return ())
222216
where
223217
sendProgressReport token report = sendNotification SMethod_Progress $ ProgressParams token $ J.toJSON report
218+
start = UE.uninterruptibleMask_ $ do
219+
t <- L.ProgressToken . L.InR . T.pack . show . hashUnique <$> liftIO newUnique
220+
r <- liftIO newBarrier
221+
_ <- sendRequest SMethod_WindowWorkDoneProgressCreate (WorkDoneProgressCreateParams t) $ \_ -> liftIO $ signalBarrier r ()
222+
sendProgressReport t $ WorkDoneProgressBegin L.AString title Nothing Nothing Nothing
223+
return t
224+
end t = do
225+
sendProgressReport t (WorkDoneProgressEnd L.AString Nothing)
224226

225227
-- Kill this to complete the progress session
226228
progressCounter ::
@@ -231,7 +233,7 @@ progressCounter ::
231233
STM Int ->
232234
IO ()
233235
progressCounter lspEnv title optProgressStyle getTodo getDone =
234-
LSP.runLspT lspEnv $ withProgressChoice title Nothing NotCancellable $ \update -> loop update 0
236+
LSP.runLspT lspEnv $ withProgressChoice title Nothing NotCancellable $ \update -> loop update 0
235237
where
236238
withProgressChoice = case optProgressStyle of
237239
TestReporting -> withProgressDummy

0 commit comments

Comments
 (0)