Skip to content

Commit c3deca2

Browse files
committed
Delay sending the create request also
1 parent 1b9cc1d commit c3deca2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lsp/src/Language/LSP/Server/Core.hs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,13 @@ withProgressBase indefinite title clientToken cancellable f = do
711711
-- for the token var to be filled if we want to use it.
712712
createToken :: m ()
713713
createToken = do
714+
-- See Note [Delayed progress reporting]
715+
-- This delays the creation of the token as well as the 'begin' message. Creating
716+
-- the token shouldn't result in any visible action on the client side since
717+
-- the title/initial percentage aren't given until the 'begin' mesage. However,
718+
-- it's neater not to create tokens that we won't use, and clients may find it
719+
-- easier to clean them up if they receive begin/end reports for them.
720+
liftIO $ threadDelay startDelay
714721
case clientToken of
715722
-- See Note [Client- versus server-initiated progress]
716723
-- Client-initiated progress
@@ -752,11 +759,6 @@ withProgressBase indefinite title clientToken cancellable f = do
752759
Cancellable -> Just True
753760
NotCancellable -> Just False
754761
begin t = do
755-
-- See Note [Delayed progress reporting]
756-
-- This delays the 'begin' message but not the creation of the token. Creating
757-
-- the token shouldn't result in any visible action on the client side since
758-
-- the title/initial percentage aren't given until the 'begin' mesage
759-
liftIO $ threadDelay startDelay
760762
(ProgressAmount pct msg) <- liftIO $ atomically $ takeTMVar reportVar
761763
sendProgressReport t $ WorkDoneProgressBegin L.AString title cancellable' msg pct
762764
update t =

0 commit comments

Comments
 (0)