Skip to content

Commit a7f5b9f

Browse files
committed
extract recordProgress
1 parent 2c5fbc9 commit a7f5b9f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ updateState _ StopProgress st = pure st
6767

6868
data InProgress = InProgress {todo, done :: !Int, current :: !(HMap.HashMap NormalizedFilePath Int)}
6969

70+
recordProgress :: NormalizedFilePath -> (Int -> Int) -> InProgress -> InProgress
71+
recordProgress file shift InProgress{..} = case HMap.alterF alter file current of
72+
((prev, new), m') ->
73+
let todo' = if isJust prev then todo else todo + 1
74+
done' = if new == 0 then done+1 else done
75+
in InProgress todo' done' m'
76+
where
77+
alter x = let x' = maybe (shift 0) shift x in ((x,x'), Just x')
78+
7079
-- | A 'ProgressReporting' that enqueues Begin and End notifications in a new
7180
-- thread, with a grace period (nothing will be sent if 'KickCompleted' arrives
7281
-- before the end of the grace period).
@@ -145,14 +154,7 @@ delayedProgressReporting before after lspEnv optProgressStyle = do
145154
-- Do not remove the eta-expansion without profiling a session with at
146155
-- least 1000 modifications.
147156
where
148-
f shift = void $ modifyVar' var $ \InProgress{..} ->
149-
case HMap.alterF alter file current of
150-
((prev, new), m') ->
151-
let todo' = if isJust prev then todo else todo + 1
152-
done' = if new == 0 then done+1 else done
153-
in InProgress todo' done' m'
154-
where
155-
alter x = let x' = maybe (shift 0) shift x in ((x,x'), Just x')
157+
f shift = modifyVar' var $ recordProgress file shift
156158

157159
mRunLspT :: Applicative m => Maybe (LSP.LanguageContextEnv c ) -> LSP.LspT c m () -> m ()
158160
mRunLspT (Just lspEnv) f = LSP.runLspT lspEnv f

0 commit comments

Comments
 (0)