Skip to content

Commit 8a9b814

Browse files
authored
Fix debouncer for 0 delay (#662)
* fix debouncer for 0 delay The indirection caused by `async (sleep 0 >> fire)` was causing the progress done messages to be sent before diagnostics, causing the code actions benchmark experiment to fail randomly. * fix exception masking
1 parent d4fd99e commit 8a9b814

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Development/IDE/Core/Debouncer.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ newAsyncDebouncer = Debouncer . asyncRegisterEvent <$> newVar Map.empty
3939
-- Events are run unmasked so it is up to the user of `registerEvent`
4040
-- to mask if required.
4141
asyncRegisterEvent :: (Eq k, Hashable k) => Var (HashMap k (Async ())) -> Seconds -> k -> IO () -> IO ()
42+
asyncRegisterEvent d 0 k fire = do
43+
modifyVar_ d $ \m -> mask_ $ do
44+
whenJust (Map.lookup k m) cancel
45+
pure $ Map.delete k m
46+
fire
4247
asyncRegisterEvent d delay k fire = modifyVar_ d $ \m -> mask_ $ do
4348
whenJust (Map.lookup k m) cancel
4449
a <- asyncWithUnmask $ \unmask -> unmask $ do

0 commit comments

Comments
 (0)