-
-
Notifications
You must be signed in to change notification settings - Fork 390
Keep instance lenses stable even if parsed results are unavailable #3545
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there's a general principle: code lenses should always use useWithStale
, since otherwise they flicker. Doesn't really matter for other stuff so much. It would be nice to write that down somewhere, not sure where.
$ liftIO | ||
$ runAction "classplugin.insertPragmaIfNotPresent.GetParsedModuleWithComments" state | ||
$ use GetParsedModuleWithComments nfp | ||
$ useWithStale GetParsedModuleWithComments nfp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, this seems like somewhere we shouldn't do it. We really want the up-to-date module to compute an edit! But because we return the edit as part of the code lens, we have to. So the thing to do in the long run would be to implment codeLens/resolve
so only the resolution method would need this. Worth a comment!
Also relevant for #3536
Should be pointing out that we have three lens behaviors now:
import lens has been using That means we'd have similar comments for every lens provider :( |
I think it's an important comment in all those places, unfortunately. Unless we want to adopt the GHC Note convention and just write a Note once and reference it from all of them. |
@michaelpj I'm a little confused, do you mean we compute lenses by fresh type checked result, and resolve it with the staled result? And, what's the meaning of |
9bee194
to
bbc365e
Compare
Other way around 😅 I think that's reasonable? It means that when you click on the lens it might be a bit out of date, but then you'll get the right then when its inserted.
The But this is future work anyway! |
Not function signature lenses only(#3541), instance signatures have the same issue.
This pr uses staled results to prevent flicker.
I take hls-class-plugin considered first just because I'm more familiar with this than familiar with function type lenses😉