-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Keep type lenses stable #3558
Keep type lenses stable #3558
Conversation
I think you should still need the position mapping otherwise the edit might go in the wrong place? It doesn't look like there's a |
Introducing |
d6f4737
to
e83b282
Compare
No particular opinion from me, I can't remember if we have any clear policy about where we're going with the |
Replace I'll open a new pr to refactor these messed code. |
@michaelpj Would you mind doing a review, I don't want mix bug fixing and refactoring |
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.
A few nits but generally looks fine.
I generally feel like we should have a usesWithStale
that returns a single position mapping for all the values, so you can request many things and get a single coherent stale mapping. The current setup probably works but feels risky to me.
Stale lens for diagnostics doesn't make sense, because we always have fresh diagnostics even if current module parsed failed( the diagnostic is So there is nothing to do if we generate lenses from diagnostics. |
But don't we mix together things we got from the diagnostics with things we got from the bindings? So the locations could be all messed up there? I haven't quite understood what's going on there. |
We don't. The secret is We have 3 modes for type lenses, only lenses from haskell-language-server/ghcide/src/Development/IDE/Plugin/TypeLenses.hs Lines 135 to 140 in 6640ebf
|
, Just range <- toCurrentRange mp beforeLine | ||
-- If `mmp` is `Nothing`, return the original range, it used by lenses from diagnostic, | ||
-- otherwise we apply `toCurrentRange`, and the guard should fail if `toCurrentRange` failed. | ||
, Just range <- maybe (Just beforeLine) (flip toCurrentRange beforeLine) mmp |
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.
I mixed the scene if mmp
is Nothing, thanks ci halt this 😅
I got the same effect without using
PositionMapping
compared to instance lenses, but don't know why.Can anyone explain this?