Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor delayedProgressReporting lsp progress api #4206

Conversation

soulomoon
Copy link
Collaborator

@soulomoon soulomoon commented May 3, 2024

It seems we have not been using lsp progress helper api any where.
Refactor delayedProgressReporting to use lsp progress api.
It is an easy target, we can see see how it works out here.
cc @michaelpj

@soulomoon soulomoon changed the title Switch delayedProgressReporting to use lsp api Refactor delayedProgressReporting lsp progress api May 3, 2024
Copy link
Collaborator

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks plausible, we can get rid of even more. And I would really like to do that generic delay ticket in lsp so we can get rid of even more !

LSP.sendNotification SMethod_Progress $
LSP.ProgressParams
{ _token = token
, _value = case optProgressStyle of
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've lost this progress-style configurability, but honestly, configurability is bad, so better to get rid of it IMO!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should get rid of the option as well, I guess.

inProgress = updateStateForFile inProgressState
return ProgressReporting{..}
where
lspShakeProgress InProgressState{..} = do
lspShakeProgressNew InProgressState{..} = do
-- first sleep a bit, so we only show progress messages if it's going to take
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I would actually really like to do this in lsp as well, see haskell/lsp#549

ghcide/src/Development/IDE/Core/ProgressReporting.hs Outdated Show resolved Hide resolved
ghcide/src/Development/IDE/Core/ProgressReporting.hs Outdated Show resolved Hide resolved
@soulomoon
Copy link
Collaborator Author

good suggestion. Swtiching to race and barrier

updateState start (Event KickStarted) (Running a) = cancel a >> Running <$> start
updateState _ (Event KickCompleted) (Running a) = cancel a $> NotStarted
updateState start (Event KickStarted) NotStarted = pure $ Running start
updateState start (Event KickStarted) (Running a) = signalBarrier a () $> Running start
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. Does this work? We signal the barrier and then go back into the running state, but won't the barrier have cancelled the whole progress reporting??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we cancel the previous job and leave the new job cancellation here.

cancelProgress <- newBarrier
LSP.runLspT lspEnv $ withProgress "Processing" Nothing Cancellable $ \update ->
race (liftIO $ waitBarrier cancelProgress) (loop update 0)
return cancelProgress
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't work: withProgress runs until the inner operation terminates! So we won't ever get here!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Sorry, I don't have a suggestion for how to do it right, I need to read it carefully again...)

Copy link
Collaborator Author

@soulomoon soulomoon May 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, right, I forget to async it. I'll add it and see how would this go

@soulomoon
Copy link
Collaborator Author

soulomoon commented May 10, 2024

Closing, now Michael picks this up in his PR #4218

@soulomoon soulomoon closed this May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants