-
-
Notifications
You must be signed in to change notification settings - Fork 370
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
Rename only if the current module compiles (#3799) #3848
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.
The changes look good to me!
Can we add a test case for this scenario?
E.g. start with a well-typed module, wait for some diagnostics, modify it such that compilation fails, wait for diagnostics, fix the compile error and request to rename an identifier.
I think, the test case should be flaky (e.g. sometimes fail) without this patch and always succeed with this patch applied.
I've added a new test for |
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.
LGTM, thanks!
handleGetHieAst state nfp = | ||
fmap (first removeGenerated) $ runActionE "Rename.GetHieAst" state $ useWithStaleE GetHieAst nfp | ||
fmap removeGenerated $ runActionE "Rename.GetHieAst" state $ useE GetHieAst 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.
fmap removeGenerated $ runActionE "Rename.GetHieAst" state $ useE GetHieAst nfp | |
-- We explicitly do not want to allow a stale version here - we only want to rename if | |
-- the module compiles, otherwise we can't guarantee that we'll rename everything, | |
-- which is bad (see https://github.com/haskell/haskell-language-server/issues/3799) | |
fmap removeGenerated $ runActionE "Rename.GetHieAst" state $ useE GetHieAst 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.
Please add a comment, otherwise this subtle but important information will be lost.
@sgillespie Do you have the time capacity to push this over the finish line? It looks like, resolving merge conflicts and updating the comment should be enough :) |
Prefer `useE` over `useWithStaleE`
@fendor I'm sorry I missed everything way back in Nov-Jan. In any case, I've updated from master and added the comment. |
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.
LGTM, thanks for being patient with us!
This PR resolves #3799 by using
useE
rather thanuseWithStaleE
. I did not implement the suggestion to have two modi, for local renames only and for cross module renaming, rather I just fixed the issue raised in the issue.