Skip to content
This repository was archived by the owner on Jan 2, 2021. It is now read-only.

Fix debouncer for 0 delay #662

Merged
merged 2 commits into from
Jun 23, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Development/IDE/Core/Debouncer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ newAsyncDebouncer = Debouncer . asyncRegisterEvent <$> newVar Map.empty
-- Events are run unmasked so it is up to the user of `registerEvent`
-- to mask if required.
asyncRegisterEvent :: (Eq k, Hashable k) => Var (HashMap k (Async ())) -> Seconds -> k -> IO () -> IO ()
asyncRegisterEvent d 0 k fire = do
modifyVar_ d $ \m -> mask_ $ do
whenJust (Map.lookup k m) cancel
pure $ Map.delete k m
fire
asyncRegisterEvent d delay k fire = modifyVar_ d $ \m -> mask_ $ do
whenJust (Map.lookup k m) cancel
a <- asyncWithUnmask $ \unmask -> unmask $ do
Expand Down