Avoid blocking when prepping pragmas for inlay#4882
Avoid blocking when prepping pragmas for inlay#4882crtschin wants to merge 1 commit intohaskell:masterfrom
Conversation
|
What about the other uses of I thought that lsp is async, just because the inlay hint request blocks doesn't mean we can't respond to other request a non-block way? |
I don't actually know. I assume in some cases we'd want to have the latest version (I saw references to
For requests it is! Notifications aren't, which is the topic of this PR. You're right though that latency here isn't that big of a problem. I think it would still be nice to have inlay's be snappy, as it reduces text jumping around in the editor. |
| fileContents <- fmap (snd . fst) $ useWithStaleFastE GetFileContents nfp | ||
| pure $ getNextPragmaInfo sessionDynFlags fileContents |
There was a problem hiding this comment.
This feels risky, if the file contents are truly outdated, the pragma info is going to be displayed incorrectly in the buffer. Are such inlay hints useful at all?
I think it is always save to wait for the result of getFileContents
Aren't they snappy already? Afaict, this delay is caused by the request handler waiting for the session setup to complete, which can easily take a long time. If we are not waiting, we are simply producing the empty list and the client needs to retry at some point, asking whether the inlay hints have updated. Once the session is initialised, I think inlay hints are already snappy and this change should only make a difference, if we are changing the session (e.g., load a new component, startup, or editing the .cabal file)? |
Appreciate the quick responses! Yeah that's correct. The vast majority of inlay requests are very quick, only lagging very seldomly, which is what this PR tries to resolve. Though you make a very good point that
I use helix, but I think it's quite similar. On With the changes in this PR, when the session is reloaded due to changing the cabal file, the inlay keeps being up to date, removing the invalid inlay when I introduce a typo in the import. Helix specifically sends inlay requests when the editor is idle, as well as when the document changes. |
Closes #4877.
One of the inlay hint providers blocked on preparing to edit pragmas. This PR creates a
*WithStaleFastversion ofgetFirstPragma, and uses it in the inlay handler.Before
After